I want to show full list of data from database using CDbCriteria and CActiveDataProvider. I make like :
$criteria=new CDbCriteria;
$criteria->alias = 'C';
if ( !$enablePagination ) {
$criteria->limit= 0;
$criteria->offset= 0;
}
debugging CDbCriteria object I see :
$criteria::CDbCriteria Object
(
[select] => *
[distinct] =>
[condition] =>
[params] => Array
(
)
[limit] => 0
[offset] => 0
[order] => name asc
[group] =>
[join] =>
[having] =>
[with] =>
[alias] => C
[together] =>
[index] =>
[scopes] =>
[_e:CComponent:private] =>
[_m:CComponent:private] =>
)
But tracing my sql I see anyway :
SELECT * FROM `tbl_category` `C` ORDER BY name asc LIMIT 10
How to remove limit condition ?
Yii 1.1.14.
Thanks!
Try this:
$criteria->limit= -1;
If limit is less than 0, then it means there is no limit.
You can't show full list of your data just using criteria. CActiveDataProvider automatically fetch the database based on pageSize
option.
Set the pageSize
option in CActiveDataProvider
like this:
$dataProvider = new CActiveDataProvider('SomeModel', array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize' => SomeModel::model()->count(),
),
));
Try this code:
$provider = new CActiveDataProvider('ModelClass', [
'pagination' => false,
'criteria' => $criteria,
]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.