can I load an object and it's relations with just a query?
so, if I have
select * from parent inner join child on parent.id = child.parent_id
could I get and array of parent beans with is ownChild informed just from that query?
something like multi mapping in dapper: https://github.com/StackExchange/dapper-dot-net#multi-mapping
there are like 30 parent with 3 or 4 child each, which it makes around 120 queries. I know that maybe I could change my model or make the queries on demand. But right now all this info goes to the client and could be edited in there, so I need the full entity.
I tried also to preload the the childs, making a query witch load al the childs, but it doesn't matter and redbean still make a query for each row. So right now I have to export without the childs and add after, but I would like to know if is there a more pretty way to do so.
Thanks in advance,
Jokin.
foreach($books as $book) {
$bookIDs[] = $book->id;
}
$pages = R::find('page', 'book_id IN ('.R::genSlots($bookIDs).')', $bookIDs);
R::findMulti('book,page', 'select from book ... join page ... etc ')
--
You received this message because you are subscribed to the Google Groups "redbeanphp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redbeanorm+...@googlegroups.com.
To post to this group, send email to redbe...@googlegroups.com.
Visit this group at http://groups.google.com/group/redbeanorm.
For more options, visit https://groups.google.com/d/optout.
Example:
$stuff = $finder->findMulti('movie,review', ' SELECT movie.*, review.* FROM movie LEFT JOIN review ON review.movie_id = movie.id');
Hello Dear Gabor,I'm beginner using Redbean and i have the same issue.i have two tables and i want to retrieve all the book and user matching- book- userMy native sql is :SELECT * FROM bookINNER JOIN userON book.owner=user.id;I tried this on redbean$app->get('/book's, function () use ($app) {// query database for all address$books= R::findMulti('book,user', ' SELECT book.*, user.* FROM book INNER JOIN user ON user.id = book.owner');// send response header for JSON content type$app->response()->header('Content-Type', 'application/json');// return JSON-encoded response body with query resultsecho json_encode(R::exportAll($books));});And i got this error below: Please could you help me?Type: ErrorExceptionCode: 4096Message: Argument 1 passed to RedBeanPHP\DuplicationManager::dup() must be an instance of RedBeanPHP\OODBBean, array given, called in D:\wamp\www\project\vendor\RedBean\rb.php on line 12214 and definedFile: C:\wamp\www\parkavenue\vendor\RedBean\rb.phpLine: 12148