Skip to content

Chunk results retrieved from a database in order to save memory.

License

Notifications You must be signed in to change notification settings

robotusers/cakephp-chunk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CakePHP Chunk plugin

Software License Build Status codecov

This plugin allows to chunk results retrieved from a database in order to save memory.

Installation

composer require robotusers/cakephp-chunk
bin/cake plugin load Robotusers/Chunk

Using the plugin

The plugin provides a custom ResultSet class which accepts Cake\ORM\Query instance.

Example:

$query = $table->find();
$results = new \Robotusers\Chunk\ORM\ResultSet($query);

foreach ($results as $result) {
    // do stuff
}

You can control how many elements are in one "chunk" (1000 by default):

$query = $table->find();
$results = new \Robotusers\Chunk\ORM\ResultSet($query, ['size' => 100]);

The plugin provides also a behavior with chunk() method:

$table->addBehavior('Robotusers/Chunk.Chunk');
$query = $table->find();
$results = $table->chunk($query, ['size' => 100]);

About

Chunk results retrieved from a database in order to save memory.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages