Carraydataprovider With Query Findall()

Hi Everyone,I’m new to Yii

When i do with CarrayDataProvider , i see this code

$rawData=Yii::app()->db->createCommand('SELECT * FROM tbl_user')->queryAll();

// or using: $rawData=User::model()->findAll();

$dataProvider=new CArrayDataProvider($rawData, array(




             'id', 'username', 'email',







// $dataProvider->getData() will return a list of arrays.

I want to know when first page reloads or i get the next page in CGridview ajax pagination , the above query is alway find all record or it’s auto add “offset, limit” attribute, ?

thanks for your help

( sorry for my bad english)


please see it…

Hope it will be helpful

Hi thangnguyen, welcome to the forum.



CArrayDataProvider always requires all the raw data without offset and limit.

You would be better use CActiveDataProvider whenever it’s possible. It will automatically apply ‘offset’ and ‘limit’ according to the pagination to optimize the query.