activerecorditerator A Helper Class to allow for iteration over a large set of active records using a CActiveDataProvider

  1. Requirements
  2. Usage
  3. Resources

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

  1. Place the class in a directory that will be imported.
  2. Create a CActiveDataProvider
  3. 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
}

Resources

10 0
7 followers
477 downloads
Yii Version: 1.1
License: MIT
Category: Database
Developed by: allain
Created on: Sep 15, 2011
Last updated: 13 years ago

Downloads

show all

Related Extensions