I have a products model with 2 many to many relationships defined.
protected $_has_many = array
(
'foodcats' => array('model' => 'foodcat', 'through' => 'products_foodcats'),
'foodgroups' => array('model' => 'foodgroup', 'through' => 'products_foodgroups')
)
I need a query where I find products with a given foodcat id and a given foodgroup name. I know I can do the following to get all products with a given foodcat id
$foodcat = ORM::factory('foodcat',$foodCatId);
$products = $foodcat->products->find_all();
But how do I query for products in that foodcat that also are in the foodgroup 'Entrees'?
Thanks!