Hi everyone,
Im using the CgridView widget to display results from a join querie.
In my controller i have this code:
$criteria->select = 't.*';
$criteria->join ='INNER JOIN user_to_post ON user_to_post.user_id = t.id';
In the user model i have this:
'posts' => array(self::MANY_MANY, 'Post','user_to_post(user_id,post_id)'),
In the CgridView, i want to display a user with his posts:
ex:
User Post
user1 post1
user1 post2
user1 post3
So i tried something like this in my view:
'columns'=>array(
array(
'name' => 'Post',
'value' => '$data->posts[<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />]->title',
),
array(
'name' => 'user',
'value' => '$data->username',
),
My question is how to pass the right index to $data->posts[] to get the associated posts for a user. For example, $data->posts[0]->title, will display post1 tree times
I hope you understand my question
Thanks