Interface Yiisoft\Db\Query\BatchQueryResultInterface
| Extends | Iterator |
|---|---|
| Implemented by | Yiisoft\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
| 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
| 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;
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;
| public abstract getQuery( ): Yiisoft\Db\Query\QueryInterface |
public function getQuery(): QueryInterface;
| public abstract indexBy( Closure|string|null $indexBy ): Yiisoft\Db\Query\BatchQueryResultInterface | ||
| $indexBy | Closure|string|null | |
public function indexBy(Closure|string|null $indexBy): static;
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;
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;
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;
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;
Signup or Login in order to comment.