Yes, you can. This is documented as "Find Multiple" in the RedBean manual.
Example with you query:
<?php
require 'rb.php'; // 4.2.4, for the record
R::setup();
// --- Fixtures ---
$parent = R::dispense('parent');
$parent->name = "Foo";
$child = R::dispense('child');
$child->name = "Bar";
$childId = R::store($child);
$parent->ownChildList[] = $child;
$parentId = R::store($parent);
// --- Multi Mapping ---
$beans = R::findMulti( 'parent,child', '
SELECT parent.*, child.* FROM parent
INNER JOIN child ON parent.id = child.parent_id
WHERE parent.id = ?
', [$parentId], [
[
'a' => 'parent',
'b' => 'child',
'matcher' => function($parent, $c) {
return $parent->id == $c->parent_id;
},
'do' => function($p, $c) {
$p->noLoad()->ownChildList[$c->id] = $c;
}
]
]);
// Ensure we don't get lazily loaded results...
R::nuke();
echo $beans['parent'][$parentId]->ownChildList[$childId]->name, "\n";
Outputs:
Bar
We win.