0 follower

Interface Yiisoft\Db\Query\BatchQueryResultInterface

ExtendsIterator
Implemented byYiisoft\Db\Query\BatchQueryResult

This interface represents a batch query from which you can retrieve data in batches.

You usually don't instantiate BatchQueryResult directly.

Instead, you obtain it by calling {@see \Yiisoft\Db\Query\Query::batch()}.

Because BatchQueryResult implements the {@see \Iterator} interface, you can iterate it to obtain a batch of data in each iteration.

For example,

$query = (new Query)->from('user');

foreach ($query->batch() as $i => $users) {
    // $users represents the rows in the $i-th batch
}

Public Methods

Hide inherited methods

Method Description Defined By
batchSize() Yiisoft\Db\Query\BatchQueryResultInterface
current() Returns the current dataset. Yiisoft\Db\Query\BatchQueryResultInterface
getBatchSize() Yiisoft\Db\Query\BatchQueryResultInterface
getQuery() Yiisoft\Db\Query\BatchQueryResultInterface
indexBy() Yiisoft\Db\Query\BatchQueryResultInterface
key() Returns the index of the current dataset. Yiisoft\Db\Query\BatchQueryResultInterface
next() Moves the internal pointer to the next dataset. Yiisoft\Db\Query\BatchQueryResultInterface
resultCallback() Sets a callback function to be called for the result of the query. Yiisoft\Db\Query\BatchQueryResultInterface
rewind() Resets the iterator to the initial state. Yiisoft\Db\Query\BatchQueryResultInterface
valid() Returns whether there is a valid dataset at the current position. Yiisoft\Db\Query\BatchQueryResultInterface

Method Details

Hide inherited methods

batchSize() public abstract method

public abstract Yiisoft\Db\Query\BatchQueryResultInterface batchSize ( integer $value )
$value integer

The number of rows to return in each batch.

                public function batchSize(int $value): static;

            
current() public abstract method

Returns the current dataset.

This method is required by the interface {@see \Iterator}.

public abstract array current ( )
return array

The current dataset.

                public function current(): array;

            
getBatchSize() public abstract method

See also batchSize().

public abstract integer getBatchSize ( )

                public function getBatchSize(): int;

            
getQuery() public abstract method

public abstract Yiisoft\Db\Query\QueryInterface getQuery ( )

                public function getQuery(): QueryInterface;

            
indexBy() public abstract method

public abstract Yiisoft\Db\Query\BatchQueryResultInterface indexBy ( Closure|string|null $indexBy )
$indexBy Closure|string|null

                public function indexBy(Closure|string|null $indexBy): static;

            
key() public abstract method

Returns the index of the current dataset.

This method is required by the interface {@see \Iterator}.

public abstract integer key ( )
return integer

The index of the current row.

                public function key(): int;

            
next() public abstract method

Moves the internal pointer to the next dataset.

This method is required by the interface {@see \Iterator}.

public abstract void next ( )
throws Yiisoft\Db\Exception\Exception
throws Yiisoft\Db\Exception\InvalidConfigException
throws Throwable

                public function next(): void;

            
resultCallback() public abstract method

Sets a callback function to be called for the result of the query.

public abstract Yiisoft\Db\Query\BatchQueryResultInterface resultCallback ( Closure|null $callback )
$callback Closure|null

                public function resultCallback(?Closure $callback): static;

            
rewind() public abstract method

Resets the iterator to the initial state.

This method is required by the interface {@see \Iterator}.

public abstract void rewind ( )
throws Yiisoft\Db\Exception\Exception
throws Yiisoft\Db\Exception\InvalidConfigException
throws Throwable

                public function rewind(): void;

            
valid() public abstract method

Returns whether there is a valid dataset at the current position.

This method is required by the interface {@see \Iterator}.

public abstract boolean valid ( )
return boolean

Whether there is a valid dataset at the current position.

                public function valid(): bool;