CActiveDataProvider only returns first few records

Dear Forum,

I have a problem.

I used CActiveDataProvider to retrieve all records from the "Product" table in the following manner:

[HTML]

$criteria = new CDbCriteria;

$criteria->select = array(‘id’,‘category’);

$criteria->distinct = true;

$dataProvider = new CActiveDataProvider(‘Product’, array(‘criteria’=>$criteria));

$resultSet = $dataProvider->getData();

[/HTML]

For some reason, it only seemed to read and return from the first few rows in the "Product" table. I got around this situation by using the findAll() method from CActiveRecord instead.

I still need to understand why it does not work with CActiveDataProvider’s getData() method.

Thank you very much!

CActiveDataProvider is mainly useful for list view components (CListView, CGridView). It therefore has a pagination object built in, which has a default pageSize of 10. If you really want all items in one go, you can change the pagesize like this:




new CActiveDataProvider('Product',array(

    'criteria'=>$criteria,

    'pagination'=>array(

        'pageSize'=>1000, // or another reasonable high value...

    ),

));

Because getData returns the data items currently available. If you want to retrieve all record you must use findAll().

NOTE: merged duplicate posts

Thank you, Mike and sensorario! I understand now.

what is solution for this dude?

i also get more data, i only need select array data only.

please advice.