So I have a submissions table that’s in a many to many relationship to a categories table, but is also in a one to one relationship with a users table. I’ve setup relations and can setup the with to pull in either the user or the categories filtered on id but am having trouble getting both at the same time. My code is as follows:
public function relations()
{
return array(
'categories' => array(self::MANY_MANY, 'Category', 'submission_category(submission_id,category_id)'),
'user' => array(self::BELONGS_TO, 'YumUser', 'user_id'),
);
}
and I can pull in the categories with
$submissions = Submission::model()->with(array(
'categories'=>array(
'on'=>'categories.id='.$id,
'together'=>true,
'joinType'=>'INNER JOIN',
)))->findAll(array(
'limit'=>$limit
));
and the users with
$submissions = Submission::model()->with('user')->findAll(array(
'limit'=>$limit));
but I am having trouble with loading both the user and categories at the same time. Any help would be greatly appreciated.