Hi all,
There’s something I don’t understand with AR / $criteria->with.
take the table structure from
http://www.yiiframework.com/doc/guide/1.1/en/database.arr
I’m trying to make CGridView of the Post Model including user and category:
I’d doing the following search:
$criteria->compare('t.title', $this->title, true)
...
$criteria->with(array(user, category))
$criteria->compare('user.name',$this->search_username,true)
...
$criteria->compare('category.name', $this->search_categoryname, true)
I have the rules set correctly in my Post Model - and I can display related data.
However, when I try to display the CGridView I get an SQL error saying category.name is unknown. And indeed, category not left outer join’ed.
But User gets properly join’ed
I also tried to create a post_category model containing a category relation.
Then, in Post, if I set up
$criteria->with(array(user, post_category.category))
I see that post_category is join’ed, but category is not
It seems to me that the ‘second level’ join is not working as I would expect it. Any ideas what I can do to ensure category gets join’ed ?