|  | 
|  | __construct (callable $getter, array $options, $callback=null, int $chunk_size=25, bool $inc_offset=true) | 
|  | Batches operations on any elgg_get_*() or compatible function that supports an options array.  More... 
 | 
|  | 
|  | setIncrementOffset (bool $increment=true) | 
|  | Increment the offset from the original options array? Setting to false is required for callbacks that delete rows.  More... 
 | 
|  | 
|  | setChunkSize (int $size=25) | 
|  | Set chunk size.  More... 
 | 
|  | 
|  | reportFailure (int $num=1) | 
|  | Report a number of failures during the batch execution, this will increase the internal offset by $num in case offsett increment is disabled.  More... 
 | 
|  | 
|  | rewind () | 
|  | Implements Iterator.  More... 
 | 
|  | 
|  | current () | 
|  | {}  More... 
 | 
|  | 
|  | key () | 
|  | {}  More... 
 | 
|  | 
|  | next () | 
|  | {}  More... 
 | 
|  | 
|  | valid () | 
|  | {}  More... 
 | 
|  | 
|  | count () | 
|  | Count the total results available at this moment.  More... 
 | 
|  | 
◆ __construct()
      
        
          | ElggBatch::__construct | ( | callable | $getter, | 
        
          |  |  | array | $options, | 
        
          |  |  |  | $callback = null, | 
        
          |  |  | int | $chunk_size = 25, | 
        
          |  |  | bool | $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 | $getter | The function used to get objects. Usually an elgg_get_*() function, but can be any valid PHP callback. |  | array | $options | The 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 | $callback | An optional callback function that all results will be passed to upon load. The callback needs to accept $result, $getter, $options. |  | int | $chunk_size | The 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_offset | Increment the offset on each fetch. This must be false for callbacks that delete rows. You can set this after the object is created with (). |  
 
- Examples
- /root/Elgg/engine/classes/ElggBatch.php.
Definition at line 200 of file ElggBatch.php.
 
 
◆ 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 
- Exceptions
- 
  
  
- Examples
- /root/Elgg/engine/classes/ElggBatch.php.
Definition at line 444 of file ElggBatch.php.
 
 
◆ current()
◆ key()
◆ next()
◆ reportFailure()
      
        
          | ElggBatch::reportFailure | ( | int | $num = 1 | ) |  | 
      
 
Report a number of failures during the batch execution, this will increase the internal offset by $num in case offsett increment is disabled. 
- Parameters
- 
  
    | int | $num | number of failures to report (default: 1) |  
 
- Returns
- void 
- Examples
- /root/Elgg/engine/classes/ElggBatch.php.
Definition at line 349 of file ElggBatch.php.
 
 
◆ rewind()
◆ setChunkSize()
      
        
          | ElggBatch::setChunkSize | ( | int | $size = 25 | ) |  | 
      
 
 
◆ setIncrementOffset()
      
        
          | ElggBatch::setIncrementOffset | ( | bool | $increment = true | ) |  | 
      
 
Increment the offset from the original options array? Setting to false is required for callbacks that delete rows. 
- Parameters
- 
  
    | bool | $increment | Set to false when deleting data |  
 
- Returns
- void 
- Examples
- /root/Elgg/engine/classes/ElggBatch.php.
Definition at line 328 of file ElggBatch.php.
 
 
◆ valid()
◆ $callbackResult
      
        
          | ElggBatch::$callbackResult = null | 
      
 
 
The documentation for this class was generated from the following file: