src/mako/database/query/Query.php
public function batch(Closure $processor, int $batchSize = 1000, int $offsetStart = 0, ?int $offsetEnd = null): void
	{
		$this->limit($batchSize);

		while(true)
		{
			$query = clone $this;

			if($offsetEnd !== null && $offsetStart >= $offsetEnd)
			{
				break;
			}

			if($offsetStart !== 0)
			{
				$query->offset($offsetStart);
			}

			$results = $query->all();

			if(count($results) > 0)
			{
				$processor($results);

				$offsetStart += $batchSize;
			}
			else
			{
				break;
			}
		}
	}
public function batch(Closure $processor, int $batchSize = 1000, int $offsetStart = 0, ?int $offsetEnd = null): void
	{
		$this->limit($batchSize);

		while(true)
		{
			$query = clone $this;

			if($offsetEnd !== null && $offsetStart >= $offsetEnd)
			{
				break;
			}

			if($offsetStart !== 0)
			{
				$query->offset($offsetStart);
			}

			$results = $query->all();

			if(count($results) > 0)
			{
				$processor($results);

				$offsetStart += $batchSize;
			}
			else
			{
				break;
			}
		}
	}
public function batch ( Closure $ processor , int $ batchSize = 1000 , int $ offsetStart = 0 , ? int $ offsetEnd = null ) : void { $ this -> limit ( $ batchSize ) ; while ( true ) { $ query = clone $ this ; if ( $ offsetEnd !== null && $ offsetStart >= $ offsetEnd ) { break ; } if ( $ offsetStart !== 0 ) { $ query -> offset ( $ offsetStart ) ; } $ results = $ query -> all ( ) ; if ( count ( $ results ) > 0 ) { $ processor ( $ results ) ; $ offsetStart += $ batchSize ; } else { break ; } } }
Fetches data in batches and passes them to the processor closure.

@param \Closure $processor   Closure that processes the results
@param int      $batchSize   Batch size
@param int      $offsetStart Offset start
@param int|null $offsetEnd   Offset end
Fetches data in batches and passes them to the processor closure .