3 namespace RedBeanPHP\Util;
5 use RedBeanPHP\OODB as OODB;
8 * Multi Bean Loader Helper
10 * This code was originally part of the facade, however it has
11 * been decided to remove unique features to service classes like
12 * this to make them available to developers not using the facade class.
14 * This helper class offers limited support for one-to-one
15 * relations by providing a service to load a set of beans
16 * with differnt types and a common ID.
18 * @file RedBeanPHP/Util/MultiLoader.php
19 * @author Gabor de Mooij and the RedBeanPHP Community
23 * copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community
24 * This source file is subject to the BSD/GPLv2 License that is bundled
25 * with this source code in the file license.txt.
30 * Loads multiple types of beans with the same ID.
31 * This might look like a strange method, however it can be useful
32 * for loading a one-to-one relation.
34 * @param OODB $oodb OODB object
35 * @param string|array $types the set of types to load at once
36 * @param mixed $id the common ID
40 public static function load( OODB $oodb, $types, $id )
42 if ( is_string( $types ) ) {
43 $types = explode( ',', $types );
46 if ( !is_array( $types ) ) {
50 foreach ( $types as $k => $typeItem ) {
51 $types[$k] = $oodb->load( $typeItem, $id );