Let's say I have three ORM models in Kohana.
class Model_Category extends ORM
{
protected $_has_many = array(
'groups' => array(
'model' => 'group',
'foreign_key' => 'category_id'
)
);
}
class Model_Group extends ORM
{
protected $_has_many = array(
'users' => array(
'model' => 'user',
'foreign_key' => 'group_id'
)
);
}
class Model_User extends ORM
{
}
I would get all the groups in a category by calling ORM::factory('category')->find($id)->groups
. I would find all the users in a group by calling ORM::factory('group')->find($id)->users
. How would I find all the users in a category?