I am trying to use ‘limit’ and ‘offset’ with CDbCriteria but they are not being respected. I am basically just modifying the view code for the blog tutorial to limit the amount of posts shown in a widget. Here is my code:
$criteria=new CDbCriteria(array(
'select'=>'*,teaser as content',
'condition'=>'status=' . Post::STATUS_PUBLISHED,
'limit'=>2,
'offset'=>0,
'order'=>'update_time DESC',
'with'=>'commentCount'
));
if(isset($_GET['tag']))
$criteria->addSearchCondition('tags',$_GET['tag']);
$dataProvider=new CActiveDataProvider('Post', array(
'pagination'=>array(
'pageSize'=>Yii::app()->params['postsPerPage'],
),
'criteria'=>$criteria,
));
Everything works properly except the limiting part. All posts are shown always. I am sure I am missing something basic but I just can’t see it
Thanks in Advance!