This extension solves a very specific problem that I had. I need to generate dynamic results using thousands of very large ActiveRecords. Doing so was causing a memory overflow on shared hosts, so I wrote this helper class that uses pagination of a CActiveDataProvider but provides a simple Iterator interface to iterate over the records in batches.
It's not fancy, it's just useful.
Requirements ¶
Yii 1.1 or above
Usage ¶
- Place the class in a directory that will be imported.
- Create a CActiveDataProvider
- Instantiate over the provider using the ActiveRecordIterator as below:
$activeDataProvider= new CActiveDataProvider('Post', ...);
$iterator = new ActiveRecordIterator($activeDataProvider, 10);
foreach ($iterator as $index => $record) {
// Do Something amazing here
}
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.