CDbCriteria

how to write MySQL query On condition

-> select * from table_name limit 10,5

here you go


$criteria = new CDbCriteria;

$criteria->offset = 5;

$criteria->limit = 10;

It can be done like this if you are utilizing CActiveRecord:




$criteria = new CDbCriteria();

$criteria->offset = 10;

$criteria->limit = 5;

$tableName = TableName::model()->findAll($criteria);



can you post your code here ?

However i think you can use CDbCommand :




$Query = Yii::app()->db->createCommand() 	

->select('*') 	

->from('table_name') 	

->limit('10,5')	

 ->queryRow();



documentation about CDbCommand : http://www.yiiframew…ildQuery-detail

Thanks ,it works.

$criteria->offset=10;//