Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Pagination Not Working.

$
0
0
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.

Viewing all articles
Browse latest Browse all 18717

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>