I faced some problem ,
when I use CActiveDataProvider I can’t set limit in its criteria,
I try bellows code, but it is not working…
$dataProvider=new CActiveDataProvider(‘MstTender’,
array(
'criteria' => array(
'condition'=>'isActive=1',
'order' => 'lastDateSubmission DESC',
'limit' => 5,
),
)
);
please any idea?
?
ressaince
(Bob Hartanto)
2
you must set the offset
$dataProvider=new CActiveDataProvider('MstTender',
array(
'criteria' => array(
'condition'=>'isActive=1',
'order' => 'lastDateSubmission DESC',
'offset'=>0,
'limit' => 5,
),
)
);
zaccaria
(Matteo Falsitta)
3
Maybe the pagination override the limit.
Try with:
$dataProvider=new CActiveDataProvider('MstTender',
array(
'criteria' => array(
'condition'=>'isActive=1',
'order' => 'lastDateSubmission DESC',
),
'pagination'=>array(
'pageSize'=>'5'
)
)
);
thnx everybody,
I found my solutions
bellows code is work nicely…
$dataProvider=new CActiveDataProvider(‘MstTender’,
array(
'criteria' => array(
'condition'=>'isActive=1',
'order' => 'lastDateSubmission DESC',
),
'pagination' => array('pageSize' => 2,),
'totalItemCount' => 2,
)
);
zaccaria
(Matteo Falsitta)
5
total item count is not needed…
hbksagar
(Sagar Krupahb2000)
6
@zaccaria,
I have tried not using totalitemCount but its not helping to limit records. I am not sure what is the issue.
Regards,
Krupa Sagar.
angelozi
(Hamideyuce)
7
CArraydataprovider available
For example,
$criteria = array(
'condition'=>'t.isActive = :active',
'params' => array('active' => 1 ),
'order' => 't.lastDateSubmission desc',
'offset' => 0,
'limit' => 30
);
$list = MstTender::model()->findAll($criteria);
$_list = new CArrayDataProvider($list, array(
'id' => 'listid',
'keyField' => 'isid', /*table primary field name*/
'pagination'=>array(
'pageSize'=>5
),
));
alumi
(Bromclorua)
8
You are right.
We need to set ‘pagination’ to false, like this:
$dataProvider = new CActiveDataProvider(
Book::model(),
array(
'criteria' => array(
'limit' => 20,
'order' => 'created DESC'
),
'pagination' => false
)
);
alex3d
(Alexdotcom)
10
Thanx! Had the same problem - found your solution!
yogii
(Azmayogi)
11
if pagination=>false limit works. is there another right way limit and pagination works together?