Yii Framework Forum: Carraydataprovider And Memory Exhaust - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Carraydataprovider And Memory Exhaust Rate Topic: -----

#1 User is offline   Pish 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 20-November 12

Posted 20 November 2012 - 09:10 AM

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!
0

#2 User is offline   Andre Lopez 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 31-May 12

Posted 01 February 2013 - 11:13 AM

View PostPish, on 20 November 2012 - 09:10 AM, said:

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?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users