MediaWiki  1.33.0
BatchRowIterator Class Reference
Inheritance diagram for BatchRowIterator:
Collaboration diagram for BatchRowIterator:

Public Member Functions

 __construct (IDatabase $db, $table, $primaryKey, $batchSize)
 
 addConditions (array $conditions)
 
 addJoinConditions (array $conditions)
 
 addOptions (array $options)
 
 current ()
 
 extractPrimaryKeys ( $row)
 Extracts the primary key(s) from a database row. More...
 
 getChildren ()
 
 hasChildren ()
 
 key ()
 
 next ()
 Fetch the next set of rows from the database. More...
 
 rewind ()
 Reset the iterator to the begining of the table. More...
 
 setFetchColumns (array $columns)
 
 valid ()
 

Protected Member Functions

 buildConditions ()
 Uses the primary key list and the maximal result row from the previous iteration to build an SQL condition sufficient for selecting the next page of results. More...
 
 buildGreaterThanCondition (array $quotedMaximumValues)
 Given an array of column names and their maximum value generate an SQL condition where all keys except the last match $quotedMaximumValues exactly and the last column is greater than the matching value in $quotedMaximumValues. More...
 

Protected Attributes

 $batchSize
 
 $conditions = []
 
 $db
 
 $fetchColumns
 
 $joinConditions = []
 
array $options = []
 Additional query options. More...
 
 $orderBy
 
 $primaryKey
 
 $table
 

Private Attributes

 $current = []
 
int $key
 key 0-indexed number of pages fetched since self::reset() More...
 

Detailed Description

Definition at line 29 of file BatchRowIterator.php.

Constructor & Destructor Documentation

◆ __construct()

BatchRowIterator::__construct ( IDatabase  $db,
  $table,
  $primaryKey,
  $batchSize 
)
Parameters
IDatabase$dbThe database to read from
string | array$tableThe name or names of the table to read from
string | array$primaryKeyThe name or names of the primary key columns
int$batchSizeThe number of rows to fetch per iteration
Exceptions
InvalidArgumentException

Definition at line 95 of file BatchRowIterator.php.

References $batchSize, $db, $primaryKey, $table, array(), and table.

Member Function Documentation

◆ addConditions()

BatchRowIterator::addConditions ( array  $conditions)
Parameters
array$conditionsQuery conditions suitable for use with IDatabase::select

Definition at line 111 of file BatchRowIterator.php.

References conditions.

Referenced by CategoryChangesAsRdf\addTimestampConditions().

◆ addJoinConditions()

BatchRowIterator::addJoinConditions ( array  $conditions)
Parameters
array$conditionsQuery join conditions suitable for use with IDatabase::select

Definition at line 127 of file BatchRowIterator.php.

References $conditions.

◆ addOptions()

BatchRowIterator::addOptions ( array  $options)
Parameters
array$optionsQuery options suitable for use with IDatabase::select

Definition at line 119 of file BatchRowIterator.php.

References options().

Referenced by CategoryChangesAsRdf\addIndex().

◆ buildConditions()

BatchRowIterator::buildConditions ( )
protected

Uses the primary key list and the maximal result row from the previous iteration to build an SQL condition sufficient for selecting the next page of results.

All except the final key use = conditions while the final key uses a > condition

Example output: [ '( foo = 42 AND bar > 7 ) OR ( foo > 42 )' ]

Returns
array The SQL conditions necessary to select the next set of rows in the batched query

Definition at line 241 of file BatchRowIterator.php.

References $name, and as.

◆ buildGreaterThanCondition()

BatchRowIterator::buildGreaterThanCondition ( array  $quotedMaximumValues)
protected

Given an array of column names and their maximum value generate an SQL condition where all keys except the last match $quotedMaximumValues exactly and the last column is greater than the matching value in $quotedMaximumValues.

Parameters
array$quotedMaximumValuesThe maximum values quoted with $this->db->addQuotes()
Returns
string An SQL condition that will select rows where all columns match the maximum value exactly except the last column which must be greater than the provided maximum value

Definition at line 284 of file BatchRowIterator.php.

References $keys, $value, and as.

◆ current()

BatchRowIterator::current ( )
Returns
array The most recently fetched set of rows from the database

Definition at line 165 of file BatchRowIterator.php.

◆ extractPrimaryKeys()

BatchRowIterator::extractPrimaryKeys (   $row)

Extracts the primary key(s) from a database row.

Parameters
stdClass$rowAn individual database row from this iterator
Returns
array Map of primary key column to value within the row

Definition at line 153 of file BatchRowIterator.php.

References $name, and as.

◆ getChildren()

BatchRowIterator::getChildren ( )
Returns
RecursiveIterator

Definition at line 202 of file BatchRowIterator.php.

◆ hasChildren()

BatchRowIterator::hasChildren ( )
Returns
bool True when this result set has rows

Definition at line 195 of file BatchRowIterator.php.

References captcha-old\count.

◆ key()

array $primaryKey The name of the primary BatchRowIterator::key ( )
Returns
int 0-indexed count of the page number fetched

Definition at line 172 of file BatchRowIterator.php.

◆ next()

BatchRowIterator::next ( )

Fetch the next set of rows from the database.

Definition at line 209 of file BatchRowIterator.php.

References $res, key, options(), and table.

◆ rewind()

BatchRowIterator::rewind ( )

Reset the iterator to the begining of the table.

Definition at line 179 of file BatchRowIterator.php.

References key.

◆ setFetchColumns()

BatchRowIterator::setFetchColumns ( array  $columns)
Parameters
array$columnsList of column names to select from the table suitable for use with IDatabase::select()

Definition at line 135 of file BatchRowIterator.php.

References captcha-old\count.

◆ valid()

BatchRowIterator::valid ( )
Returns
bool True when the iterator is in a valid state

Definition at line 188 of file BatchRowIterator.php.

Member Data Documentation

◆ $batchSize

BatchRowIterator::$batchSize
protected

Definition at line 49 of file BatchRowIterator.php.

Referenced by __construct().

◆ $conditions

BatchRowIterator::$conditions = []
protected

Definition at line 55 of file BatchRowIterator.php.

Referenced by addJoinConditions().

◆ $current

BatchRowIterator::$current = []
private

Definition at line 76 of file BatchRowIterator.php.

◆ $db

BatchRowIterator::$db
protected

Definition at line 34 of file BatchRowIterator.php.

Referenced by __construct().

◆ $fetchColumns

BatchRowIterator::$fetchColumns
protected

Definition at line 66 of file BatchRowIterator.php.

◆ $joinConditions

array BatchRowIterator::$joinConditions = []
protected

Definition at line 60 of file BatchRowIterator.php.

◆ $key

int BatchRowIterator::$key
private

key 0-indexed number of pages fetched since self::reset()

Definition at line 81 of file BatchRowIterator.php.

◆ $options

array BatchRowIterator::$options = []
protected

Additional query options.

Definition at line 86 of file BatchRowIterator.php.

◆ $orderBy

BatchRowIterator::$orderBy
protected

Definition at line 71 of file BatchRowIterator.php.

◆ $primaryKey

BatchRowIterator::$primaryKey
protected

Definition at line 44 of file BatchRowIterator.php.

Referenced by __construct().

◆ $table

BatchRowIterator::$table
protected

Definition at line 39 of file BatchRowIterator.php.

Referenced by __construct().


The documentation for this class was generated from the following file: