Hi,
On a forum app I need to select the topics with its last post and the topics have to be ordered by its last post created date.
I’m using:
$topicsDP = new CActiveDataProvider('Topic', array(
'criteria'=>array(
'together'=>true,
'condition'=>Yii::app()->db->quoteColumnName('t.forum_id').'=:fid',
'params'=>array(':fid'=>$forumID),
'with'=>array(
'posts'=>array(
'joinType'=>'INNER JOIN',
'order'=>Yii::app()->db->quoteColumnName('posts.created').' DESC',
'limit'=>1,
'distinct'=>true,
),
),
),
'pagination'=>array(
'pageSize'=>3,
),
));
When testing I have 4 topics, the first page is ok but the second isn’t. I think it is because the “OFFSET 3” is also affecting the posts select.
How can I do this?
Also, all posts are beeing select, is there some way of only selecting the last one?
Thanks.