PHP Класс yii\db\BatchQueryResult

You usually do not instantiate BatchQueryResult directly. Instead, you obtain it by calling [[Query::batch()]] or [[Query::each()]]. Because BatchQueryResult implements the [[\Iterator]] interface, you can iterate it to obtain a batch of data in each iteration. For example, php $query = (new Query)->from('user'); foreach ($query->batch() as $i => $users) { $users represents the rows in the $i-th batch } foreach ($query->each() as $user) { }
С версии: 2.0
Автор: Qiang Xue ([email protected])
Наследование: extends yii\base\Object, implements Iterator
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$batchSize the number of rows to be returned in each batch.
$db the DB connection to be used when performing batch query. If null, the "db" application component will be used.
$each whether to return a single row during each iteration. If false, a whole batch of rows will be returned in each iteration.
$query the query object associated with this batch query. Do not modify this property directly unless after BatchQueryResult::reset is called explicitly.

Открытые методы

Метод Описание
__destruct ( ) Destructor.
current ( ) : mixed Returns the current dataset.
key ( ) : integer Returns the index of the current dataset.
next ( ) Moves the internal pointer to the next dataset.
reset ( ) Resets the batch query.
rewind ( ) Resets the iterator to the initial state.
valid ( ) : boolean Returns whether there is a valid dataset at the current position.

Защищенные методы

Метод Описание
fetchData ( ) : array Fetches the next batch of data.

Описание методов

__destruct() публичный Метод

Destructor.
public __destruct ( )

current() публичный Метод

This method is required by the interface [[\Iterator]].
public current ( ) : mixed
Результат mixed the current dataset.

fetchData() защищенный Метод

Fetches the next batch of data.
protected fetchData ( ) : array
Результат array the data fetched

key() публичный Метод

This method is required by the interface [[\Iterator]].
public key ( ) : integer
Результат integer the index of the current row.

next() публичный Метод

This method is required by the interface [[\Iterator]].
public next ( )

reset() публичный Метод

This method will clean up the existing batch query so that a new batch query can be performed.
public reset ( )

rewind() публичный Метод

This method is required by the interface [[\Iterator]].
public rewind ( )

valid() публичный Метод

This method is required by the interface [[\Iterator]].
public valid ( ) : boolean
Результат boolean whether there is a valid dataset at the current position.

Описание свойств

$batchSize публичное свойство

the number of rows to be returned in each batch.
public $batchSize

$db публичное свойство

the DB connection to be used when performing batch query. If null, the "db" application component will be used.
public $db

$each публичное свойство

whether to return a single row during each iteration. If false, a whole batch of rows will be returned in each iteration.
public $each

$query публичное свойство

the query object associated with this batch query. Do not modify this property directly unless after BatchQueryResult::reset is called explicitly.
public $query