Kohana: How to load all many-to-many relationships in one query

AlldigitalbayD

New Member
I have a database relationship that looks something like this:\[code\]booking -> person <-> option-> : one-to-many<-> : many-to-many\[/code\]I now need to list all the persons in a booking, with all their options. Using ORM in kohana I can load all persons like this:\[code\]$persons = ORM::factory('booking', $id)->persons->find_all();\[/code\]I could then loop over the persons and get all their options, but that would mean one query per person. Is there a clever way to load this without having to do that? What I would like to end up with is something like this:\[code\]booking
 
Back
Top