Elgg  Version 3.0
Public Member Functions | Public Attributes | List of all members
ElggBatch Class Reference
Inheritance diagram for ElggBatch:
Elgg\BatchResult

Public Member Functions

 __construct (callable $getter, $options, $callback=null, $chunk_size=25, $inc_offset=true)
 Batches operations on any elgg_get_*() or compatible function that supports an options array. More...
 
 setIncrementOffset ($increment=true)
 Increment the offset from the original options array? Setting to false is required for callbacks that delete rows. More...
 
 setChunkSize ($size=25)
 Set chunk size. More...
 
 rewind ()
 Implements Iterator. More...
 
 current ()
 {} More...
 
 key ()
 {} More...
 
 next ()
 {} More...
 
 valid ()
 {} More...
 
 count ()
 Count the total results available at this moment. More...
 

Public Attributes

 $callbackResult = null
 

Detailed Description

Definition at line 73 of file ElggBatch.php.

Constructor & Destructor Documentation

ElggBatch::__construct ( callable  $getter,
  $options,
  $callback = null,
  $chunk_size = 25,
  $inc_offset = true 
)

Batches operations on any elgg_get_*() or compatible function that supports an options array.

Instead of returning all objects in memory, it goes through $chunk_size objects, then requests more from the server. This avoids OOM errors.

Parameters
callable$getterThe function used to get objects. Usually an elgg_get_*() function, but can be any valid PHP callback.
array$optionsThe options array to pass to the getter function. If limit is not set, 10 is used as the default. In most cases that is not what you want.
mixed$callbackAn optional callback function that all results will be passed to upon load. The callback needs to accept $result, $getter, $options.
int$chunk_sizeThe number of entities to pull in before requesting more. You have to balance this between running out of memory in PHP and hitting the db server too often.
bool$inc_offsetIncrement the offset on each fetch. This must be false for callbacks that delete rows. You can set this after the object is created with ElggBatch::setIncrementOffset().
Examples:
/root/Elgg/engine/classes/ElggBatch.php.

Definition at line 209 of file ElggBatch.php.

Member Function Documentation

ElggBatch::count ( )

Count the total results available at this moment.

As this performs a separate query, the count returned may not match the number of results you can fetch via iteration on a very active DB.

See also
Countable::count()
Returns
int
Examples:
/root/Elgg/engine/classes/ElggBatch.php.

Definition at line 447 of file ElggBatch.php.

ElggBatch::current ( )

{}

Examples:
/root/Elgg/engine/classes/ElggBatch.php.

Definition at line 387 of file ElggBatch.php.

ElggBatch::key ( )

{}

Examples:
/root/Elgg/engine/classes/ElggBatch.php.

Definition at line 394 of file ElggBatch.php.

ElggBatch::next ( )

{}

Examples:
/root/Elgg/engine/classes/ElggBatch.php.

Definition at line 401 of file ElggBatch.php.

ElggBatch::rewind ( )

Implements Iterator.

{}

Examples:
/root/Elgg/engine/classes/ElggBatch.php.

Definition at line 372 of file ElggBatch.php.

ElggBatch::setChunkSize (   $size = 25)

Set chunk size.

Parameters
int$sizeSize
Returns
void
Examples:
/root/Elgg/engine/classes/ElggBatch.php.

Definition at line 362 of file ElggBatch.php.

ElggBatch::setIncrementOffset (   $increment = true)

Increment the offset from the original options array? Setting to false is required for callbacks that delete rows.

Parameters
bool$incrementSet to false when deleting data
Returns
void
Examples:
/root/Elgg/engine/classes/ElggBatch.php.

Definition at line 353 of file ElggBatch.php.

ElggBatch::valid ( )

{}

Examples:
/root/Elgg/engine/classes/ElggBatch.php.

Definition at line 430 of file ElggBatch.php.

Member Data Documentation

ElggBatch::$callbackResult = null
Examples:
/root/Elgg/engine/classes/ElggBatch.php.

Definition at line 164 of file ElggBatch.php.


The documentation for this class was generated from the following file: