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 Yiisoft\Db\Query\Query::batch().

Because BatchQueryResult implements the 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 batchSize( integer $value ): Yiisoft\Db\Query\BatchQueryResultInterface
$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 Iterator.

public abstract current( ): array
return array

The current dataset.

                public function current(): array;

            
getBatchSize() public abstract method

See also batchSize().

public abstract getBatchSize( ): integer

                public function getBatchSize(): int;

            
getQuery() public abstract method

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

                public function getQuery(): QueryInterface;

            
indexBy() public abstract method

public abstract indexBy( Closure|string|null $indexBy ): Yiisoft\Db\Query\BatchQueryResultInterface
$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 Iterator.

public abstract key( ): integer
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 Iterator.

public abstract next( ): void
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 resultCallback( Closure|null $callback ): Yiisoft\Db\Query\BatchQueryResultInterface
$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 Iterator.

public abstract rewind( ): void
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 Iterator.

public abstract valid( ): boolean
return boolean

Whether there is a valid dataset at the current position.

                public function valid(): bool;