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'=>'user',

    'sort'=>array(

        'attributes'=>array(

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

        ),

    ),

    'pagination'=>array(

        'pageSize'=>10,

    ),

));

// $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)

Hi,

please see it…

http://www.yiiplayground.com/index.php?r=UiModule/dataview/gridView

Hope it will be helpful

Hi thangnguyen, welcome to the forum.

Yes.

No.

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.

Thanks.