I have modelled a relation like this is RedBeanPHP:
Car
id color ownPart
Part
id name
So RedBean creates the SQL tables as expected:
Car
id color
Part
id name car_id
This works great.
However, I have other tables in my DB, e.g. a User
that also has a car_id
identifying the users car.
When I want to query all Car
s and its children (Part
s) by
$cars = R::find('car');
$foo = R::exportAll( $cars ); echo json_encode($foo);
the JSON also contains every User
related to a car.
How can I query just the cars with their "real" children?
exportAll
specifies a third parameter$filter
that you should be able to use to specify which relationships are also exported: