.. JOIN review'
this method will return movie and review beans.
Example:
$stuff = $finder->findMulti('movie,review', '
SELECT movie.*, review.* FROM movie
LEFT JOIN review ON review.movie_id = movie.id');
After this operation, $stuff will contain an entry 'movie' containing all
movies and an entry named 'review' containing all reviews (all beans).
You can also pass bindings.
If you want to re-map your beans, so you can use $movie->ownReviewList without
having RedBeanPHP executing an SQL query you can use the fourth parameter to
define a selection of remapping closures.
The remapping argument (optional) should contain an array of arrays.
Each array in the remapping array should contain the following entries:
array(
'a' => TYPE A
'b' => TYPE B
'matcher' => MATCHING FUNCTION ACCEPTING A, B and ALL BEANS
'do' => OPERATION FUNCTION ACCEPTING A, B, ALL BEANS, ALL REMAPPINGS
)
Using this mechanism you can build your own 'preloader' with tiny function
snippets (and those can be re-used and shared online of course).
Example:
array(
'a' => 'movie' //define A as movie
'b' => 'review' //define B as review
'matcher' => function( $a, $b ) {
return ( $b->movie_id == $a->id ); //Perform action if review.movie_id equals movie.id
}
'do' => function( $a, $b ) {
$a->noLoad()->ownReviewList[] = $b; //Add the review to the movie
$a->clearHistory(); //optional, act 'as if these beans have been loaded through ownReviewList'.
}
)
The Query Template parameter is optional as well but can be used to
set a different SQL template (sprintf-style) for processing the original query. public findMulti ( string | array $types, $sql, array $bindings = [], array $remappings = [], string $queryTemplate = ' %s.%s AS %s__%s' ) : array | ||
$types | string | array | a list of types (either array or comma separated string) |
$bindings | array | optional, bindings for SQL query |
$remappings | array | optional, an array of remapping arrays |
$queryTemplate | string | optional, query template |
Результат | array |