Well, I’ve tried a lot but cannot get this piece of code working as expected.
Following is inside an action method,
$dataProvider=new CActiveDataProvider('Tips', array(
'criteria'=>array('order'=>'create_time DESC','limit'=>1)
));
The order of the output is descending but ‘limit’? It just does not work. I’m expecting to get a single result after putting ‘limit’->1 and yet it gives me data from all the rows.
The view file corresponding to this contains,
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'summaryText'=>'',
'itemView'=>'_tips',
)); ?>
Really not able to understand what is going wrong here. Kindly help.
perochak
(Amjad Mughal)
August 18, 2011, 10:20pm
2
It will work only when you set the pagination to false in CActiveDataProvider
Well, I’ve tried a lot but cannot get this piece of code working as expected.
Following is inside an action method,
$dataProvider=new CActiveDataProvider('Tips', array(
'criteria'=>array('order'=>'create_time DESC','limit'=>1)
));
The order of the output is descending but ‘limit’? It just does not work. I’m expecting to get a single result after putting ‘limit’->1 and yet it gives me data from all the rows.
The view file corresponding to this contains,
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'summaryText'=>'',
'itemView'=>'_tips',
)); ?>
Really not able to understand what is going wrong here. Kindly help.
hi friends you can set limit by
$dataProvider=new CActiveDataProvider('model', array(
'criteria'=>array(
'order'=>'create_time DESC',
),
'pagination' => array('pageSize' => 8,),
'totalItemCount' => 8,
));
its working nice.
fburhan89
(Sefburhan)
May 20, 2013, 12:22pm
5
Well, I’ve tried a lot but cannot get this piece of code working as expected.
Following is inside an action method,
$dataProvider=new CActiveDataProvider('Tips', array(
'criteria'=>array('order'=>'create_time DESC','limit'=>1)
));
The order of the output is descending but ‘limit’? It just does not work. I’m expecting to get a single result after putting ‘limit’->1 and yet it gives me data from all the rows.
The view file corresponding to this contains,
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'summaryText'=>'',
'itemView'=>'_tips',
)); ?>
Really not able to understand what is going wrong here. Kindly help.
http://www.yiiframework.com/doc/api/1.1/CDbCriteria#limit-detail