Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
ElggBatch Class Reference
Inheritance diagram for ElggBatch:

Public Member Functions

 __construct ($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...
 
 reportIncompleteEntity (\stdClass $row)
 Tell the process that an entity was incomplete during a fetch. More...
 
 setIncrementOffset ($increment=true)
 Increment the offset from the original options array? Setting to false is required for callbacks that delete rows. More...
 
 rewind ()
 Implements Iterator. More...
 
 current ()
 PHP Iterator Interface. More...
 
 key ()
 PHP Iterator Interface. More...
 
 next ()
 PHP Iterator Interface. More...
 
 valid ()
 PHP Iterator Interface. More...
 

Public Attributes

 $callbackResult = null
 

Detailed Description

Definition at line 57 of file ElggBatch.php.

Constructor & Destructor Documentation

ElggBatch::__construct (   $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
string$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().

Definition at line 187 of file ElggBatch.php.

Member Function Documentation

ElggBatch::current ( )

PHP Iterator Interface.

See Also
Iterator::current()
Returns
mixed

Definition at line 374 of file ElggBatch.php.

ElggBatch::key ( )

PHP Iterator Interface.

See Also
Iterator::key()
Returns
int

Definition at line 384 of file ElggBatch.php.

ElggBatch::next ( )

PHP Iterator Interface.

See Also
Iterator::next()
Returns
mixed

Definition at line 394 of file ElggBatch.php.

ElggBatch::reportIncompleteEntity ( \stdClass  $row)

Tell the process that an entity was incomplete during a fetch.

Parameters
\stdClass$rowprivate

Definition at line 240 of file ElggBatch.php.

ElggBatch::rewind ( )

Implements Iterator.

PHP Iterator Interface

See Also
Iterator::rewind()
Returns
void

Definition at line 356 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

Definition at line 342 of file ElggBatch.php.

ElggBatch::valid ( )

PHP Iterator Interface.

See Also
Iterator::valid()
Returns
bool

Definition at line 426 of file ElggBatch.php.

Member Data Documentation

ElggBatch::$callbackResult = null

Definition at line 142 of file ElggBatch.php.


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