|
MediaWiki master
|
Result wrapper for grabbing data queried from an IDatabase object. More...
Inherits Wikimedia\Rdbms\IResultWrapper.
Inherited by Wikimedia\Rdbms\FakeResultWrapper, Wikimedia\Rdbms\MysqliResultWrapper, Wikimedia\Rdbms\PostgresResultWrapper, and Wikimedia\Rdbms\SqliteResultWrapper.

Public Member Functions | ||||||
| count () | ||||||
Get the number of rows in a result object.
| ||||||
| current () | ||||||
| ||||||
| fetchObject () | ||||||
Fetch the next row from the given result object, in object form.Fields can be retrieved with $row->fieldname, with fields acting like member variables. If no more rows are available, false is returned.
| ||||||
| fetchRow () | ||||||
Fetch the next row from the given result object, in associative array form.Fields are retrieved with $row['fieldname']. If no more rows are available, false is returned.
| ||||||
| free () | ||||||
| Free a result object.This either saves memory in PHP (buffered queries) or on the server (unbuffered queries). In general, queries are not large enough in result sets for this to be worth calling. | ||||||
| getFieldNames () | ||||||
Get the names of the fields in the result.
| ||||||
| key () | ||||||
| ||||||
| next () | ||||||
| ||||||
| numRows () | ||||||
Get the number of rows in a result object.
| ||||||
| rewind () | ||||||
| seek ( $pos) | ||||||
Change the position of the cursor in a result object.See mysql_data_seek()
| ||||||
| valid () | ||||||
Protected Member Functions | |
| doFetchObject () | |
| Get the next row as a stdClass object, or false if iteration has proceeded past the end. | |
| doFetchRow () | |
| Get the next row as an array containing the data duplicated, once with string keys and once with numeric keys, per the PDO::FETCH_BOTH convention. | |
| doFree () | |
| Free underlying data. | |
| doGetFieldNames () | |
| Get the field names in the result set. | |
| doNumRows () | |
| Get the number of rows in the result set. | |
| doSeek ( $pos) | |
| Modify the current cursor position to the row with the specified offset. | |
Protected Attributes | |
| int | $currentPos = 0 |
| The offset of the current row that would be returned by current() and may have been previously returned by fetchObject(). | |
| stdClass array bool null | $currentRow |
| The row at $this->currentPos, or null if it has not yet been retrieved, or false if the current row was past the end. | |
| int | $nextPos = 0 |
| The offset of the row that would be returned by the next call to fetchObject(). | |
Result wrapper for grabbing data queried from an IDatabase object.
Only IDatabase-related classes should construct these. Other code may use the FakeResultWrapper class for convenience or compatibility shims.
Note that using the Iterator methods in combination with the non-Iterator IDatabase result iteration functions may cause rows to be skipped or repeated.
By default, this will use the iteration methods of the IDatabase handle if provided. Subclasses can override methods to make it solely work on the result resource instead.
Definition at line 22 of file ResultWrapper.php.
| Wikimedia\Rdbms\ResultWrapper::count | ( | ) |
Get the number of rows in a result object.
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 99 of file ResultWrapper.php.
References doNumRows(), and return.
Referenced by Wikimedia\Rdbms\FakeResultWrapper\doNumRows(), and Wikimedia\Rdbms\SqliteResultWrapper\doNumRows().
| Wikimedia\Rdbms\ResultWrapper::current | ( | ) |
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 145 of file ResultWrapper.php.
References fetchObject().
|
abstractprotected |
Get the next row as a stdClass object, or false if iteration has proceeded past the end.
The offset within the result set is in $this->currentPos.
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper, Wikimedia\Rdbms\MysqliResultWrapper, Wikimedia\Rdbms\PostgresResultWrapper, and Wikimedia\Rdbms\SqliteResultWrapper.
Referenced by fetchObject().
|
abstractprotected |
Get the next row as an array containing the data duplicated, once with string keys and once with numeric keys, per the PDO::FETCH_BOTH convention.
Or false if iteration has proceeded past the end.
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper, Wikimedia\Rdbms\MysqliResultWrapper, Wikimedia\Rdbms\PostgresResultWrapper, and Wikimedia\Rdbms\SqliteResultWrapper.
Referenced by fetchRow().
|
abstractprotected |
Free underlying data.
It is not necessary to do anything.
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper, Wikimedia\Rdbms\MysqliResultWrapper, Wikimedia\Rdbms\PostgresResultWrapper, and Wikimedia\Rdbms\SqliteResultWrapper.
Referenced by free().
|
abstractprotected |
Get the field names in the result set.
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper, Wikimedia\Rdbms\MysqliResultWrapper, Wikimedia\Rdbms\PostgresResultWrapper, and Wikimedia\Rdbms\SqliteResultWrapper.
Referenced by getFieldNames().
|
abstractprotected |
Get the number of rows in the result set.
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper, Wikimedia\Rdbms\MysqliResultWrapper, Wikimedia\Rdbms\PostgresResultWrapper, and Wikimedia\Rdbms\SqliteResultWrapper.
|
abstractprotected |
Modify the current cursor position to the row with the specified offset.
If $pos is out of bounds, the behaviour is undefined.
| int | $pos |
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper, Wikimedia\Rdbms\MysqliResultWrapper, Wikimedia\Rdbms\PostgresResultWrapper, and Wikimedia\Rdbms\SqliteResultWrapper.
| Wikimedia\Rdbms\ResultWrapper::fetchObject | ( | ) |
Fetch the next row from the given result object, in object form.Fields can be retrieved with $row->fieldname, with fields acting like member variables. If no more rows are available, false is returned.
| DBUnexpectedError | Thrown if the database returns an error |
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 104 of file ResultWrapper.php.
References doFetchObject().
| Wikimedia\Rdbms\ResultWrapper::fetchRow | ( | ) |
Fetch the next row from the given result object, in associative array form.Fields are retrieved with $row['fieldname']. If no more rows are available, false is returned.
| DBUnexpectedError | Thrown if the database returns an error |
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 111 of file ResultWrapper.php.
References doFetchRow().
| Wikimedia\Rdbms\ResultWrapper::free | ( | ) |
Free a result object.This either saves memory in PHP (buffered queries) or on the server (unbuffered queries). In general, queries are not large enough in result sets for this to be worth calling.
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 134 of file ResultWrapper.php.
References doFree().
| Wikimedia\Rdbms\ResultWrapper::getFieldNames | ( | ) |
Get the names of the fields in the result.
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 167 of file ResultWrapper.php.
References doGetFieldNames().
| Wikimedia\Rdbms\ResultWrapper::key | ( | ) |
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 152 of file ResultWrapper.php.
References return.
| Wikimedia\Rdbms\ResultWrapper::next | ( | ) |
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 157 of file ResultWrapper.php.
References fetchObject().
| Wikimedia\Rdbms\ResultWrapper::numRows | ( | ) |
Get the number of rows in a result object.
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 94 of file ResultWrapper.php.
References doNumRows().
Referenced by Wikimedia\Rdbms\QueryStatus\__construct(), seek(), and valid().
| Wikimedia\Rdbms\ResultWrapper::rewind | ( | ) |
Definition at line 139 of file ResultWrapper.php.
References seek().
| Wikimedia\Rdbms\ResultWrapper::seek | ( | $pos | ) |
Change the position of the cursor in a result object.See mysql_data_seek()
| OutOfBoundsException |
| int | $pos |
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 118 of file ResultWrapper.php.
References numRows().
Referenced by rewind().
| Wikimedia\Rdbms\ResultWrapper::valid | ( | ) |
Definition at line 161 of file ResultWrapper.php.
|
protected |
The offset of the current row that would be returned by current() and may have been previously returned by fetchObject().
Definition at line 33 of file ResultWrapper.php.
Referenced by Wikimedia\Rdbms\FakeResultWrapper\doFetchObject(), and Wikimedia\Rdbms\SqliteResultWrapper\doFetchObject().
|
protected |
The row at $this->currentPos, or null if it has not yet been retrieved, or false if the current row was past the end.
Definition at line 39 of file ResultWrapper.php.
|
protected |
The offset of the row that would be returned by the next call to fetchObject().
Definition at line 27 of file ResultWrapper.php.