Problem with CActiveDataProvider

Hi. I want to get last 10 records from database by using CActiveDataProvider. Here is my configuration:

	public function actionLast()


		$dataProvider=new CActiveDataProvider('Models',array(


			'order'=>'id DESC',








Тhe problem is that CActiveDataProvider returns all the records, not the last 10, but at least they are ordered. Am I missing something with the configuration?

What’s the generated SQL? Also, if you don’t want to use pagination, you should configure ‘pagination’=>false.

I don’t know if it’s by design… but “limit” functions only if pagination is set to false!

That’s because if pagination is not false, the pagination’s limit will be used instead.

I tryed this one:





but I get this error: Property "CPagination.limit" is read only.

I set pagination to false and It works fine now. Thank you very much :)

@mdombla: for pagination, please set pageSize instead.

First let me tell you that this framework is great !!!

I would like to retreive first 100 rows but to display them in pages… 10 items per page…

Something like this would be usable:





For this special feature, you need to override CActiveDataProvider::calculateTotalItemCount() as:

    protected function calculateTotalItemCount()



        return $count>100 ? 100 : $count;