Carraydataprovider And Memory Exhaust

Hi,

Few days ago I started using Yii (I switched from CakePHP) and I’m migrating an existing application (I’m really really happy to have switched to Yii).

This app uses mysql and has lots of stored procedures mainly for retrieving data (just a few for insert/update); so, I’m currently using DAO -to retrieve the records pulled from stored procedures- and CArrayDataProvider with pagination to display them on the screen.

The existing app avoids pulling so many records in order to prevent exhausting the memory, but there are situations where +5000 records are retrieved and I’m a bit concerned about exhausting the memory using CArrayDataProvider.

So, a couple of questions came to me:

  1. When using pagination in a CArrayDataProvider, only the records of the current page are pulled into the array? or it contains all the records of the query result? If it contains all the records, is there a recommended way to do something in the CDbCommand or CArrayDataProvider to avoid this and just pull the records of the current page in it?

  2. I generated the CRUD for an entity and I see that the views generated assume that $data is an AR object:


 echo CHtml::link(CHtml::encode($data->id), array('view', 'id'=>$data->id));

Since the data will be coming as an array, is it better to cast the array in the view: $data = (object)$data? or just change the above like code as:


 echo CHtml::link(CHtml::encode($data['id']), array('view', 'id'=>$data['id']));

?

Thanks in advance!

Hello, You got some information to your question?