FOF30\Model\DataModel::chunk PHP Method

chunk() public method

Process a large collection of records a few at a time.
public chunk ( integer $chunkSize, callable $callback )
$chunkSize integer How many records to process at once
$callback callable A callable to process each record
    public function chunk($chunkSize, $callback)
    {
        $totalItems = $this->count();
        if (!$totalItems) {
            return $this;
        }
        $start = 0;
        while ($start < $totalItems - 1) {
            $this->get(true, $start, $chunkSize)->transform($callback);
            $start += $chunkSize;
        }
        return $this;
    }