没有命名空间的类 yii yii\base yii\behaviors yii\caching yii\captcha yii\console yii\console\controllers yii\console\widgets yii\data yii\db yii\db\conditions yii\db\cubrid yii\db\cubrid\conditions yii\db\mssql yii\db\mssql\conditions yii\db\mysql yii\db\oci yii\db\oci\conditions yii\db\pgsql yii\db\sqlite yii\db\sqlite\conditions yii\di yii\filters yii\filters\auth yii\grid yii\helpers yii\i18n yii\log yii\mail yii\mutex yii\rbac yii\rest yii\test yii\validators yii\web yii\widgets

Class yii\db\BatchQueryResult

继承yii\db\BatchQueryResult » yii\base\BaseObject
实现Iterator, yii\base\Configurable
可用版本自2.0
源码 https://github.com/yiichina/yii2/blob/api/framework/db/BatchQueryResult.php

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

You usually do not instantiate BatchQueryResult directly. Instead, you obtain it by calling yii\db\Query::batch() or yii\db\Query::each(). 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
}
foreach ($query->each() as $user) {
}

公共属性

隐藏继承的属性

属性类型描述被定义在
$batchSize integer The number of rows to be returned in each batch. yii\db\BatchQueryResult
$db yii\db\Connection The DB connection to be used when performing batch query. yii\db\BatchQueryResult
$each boolean Whether to return a single row during each iteration. yii\db\BatchQueryResult
$query yii\db\Query The query object associated with this batch query. yii\db\BatchQueryResult

公共方法

隐藏继承的方法

方法描述被定义在
__call() Calls the named method which is not a class method. yii\base\BaseObject
__construct() Constructor. yii\base\BaseObject
__destruct() Destructor. yii\db\BatchQueryResult
__get() Returns the value of an object property. yii\base\BaseObject
__isset() Checks if a property is set, i.e. defined and not null. yii\base\BaseObject
__set() Sets value of an object property. yii\base\BaseObject
__unset() Sets an object property to null. yii\base\BaseObject
canGetProperty() Returns a value indicating whether a property can be read. yii\base\BaseObject
canSetProperty() Returns a value indicating whether a property can be set. yii\base\BaseObject
className() Returns the fully qualified name of this class. yii\base\BaseObject
current() Returns the current dataset. yii\db\BatchQueryResult
hasMethod() Returns a value indicating whether a method is defined. yii\base\BaseObject
hasProperty() Returns a value indicating whether a property is defined. yii\base\BaseObject
init() Initializes the object. yii\base\BaseObject
key() Returns the index of the current dataset. yii\db\BatchQueryResult
next() Moves the internal pointer to the next dataset. yii\db\BatchQueryResult
reset() Resets the batch query. yii\db\BatchQueryResult
rewind() Resets the iterator to the initial state. yii\db\BatchQueryResult
valid() Returns whether there is a valid dataset at the current position. yii\db\BatchQueryResult

受保护的方法

隐藏继承的方法

方法描述被定义在
fetchData() Fetches the next batch of data. yii\db\BatchQueryResult

属性详情

$batchSize 公共 属性

The number of rows to be returned in each batch.

public integer $batchSize 100
$db 公共 属性

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

public yii\db\Connection $db null
$each 公共 属性

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

public boolean $each false
$query 公共 属性

The query object associated with this batch query. Do not modify this property directly unless after reset() is called explicitly.

public yii\db\Query $query null

方法详情

__destruct() 公共 方法

Destructor.

public void __destruct()
current() 公共 方法

Returns the current dataset.

This method is required by the interface Iterator.

public mixed current()
return mixed

The current dataset.

fetchData() 受保护 方法

Fetches the next batch of data.

protected array fetchData()
return array

The data fetched

key() 公共 方法

Returns the index of the current dataset.

This method is required by the interface Iterator.

public integer key()
return integer

The index of the current row.

next() 公共 方法

Moves the internal pointer to the next dataset.

This method is required by the interface Iterator.

public void next()
reset() 公共 方法

Resets the batch query.

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

public void reset()
rewind() 公共 方法

Resets the iterator to the initial state.

This method is required by the interface Iterator.

public void rewind()
valid() 公共 方法

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

This method is required by the interface Iterator.

public boolean valid()
return boolean

Whether there is a valid dataset at the current position.