yiisoft/yii — Issue #432: Possible error in docs for the CArrayDataProvider
Author: cherepnin
Created: 2012-03-02 10:17:43+00:00
State: open

In the CArrayDataProvider.php	there is an example with following lines:

* $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 believe that 'id' key in should be changed to keyFiled, so it will look like

$dataProvider=new CArrayDataProvider($rawData, array(
* 'keyField'=>'user',

Otherwise it causes the "undefined index" error on line 102 in this class.