MediaWiki REL1_37
|
Result wrapper for grabbing data queried from an IDatabase object. More...
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. | |
fetchRow () | |
Fetch the next row from the given result object, in associative array form. | |
free () | |
Free a result object. | |
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. | |
valid () | |
Static Public Member Functions | |
static | unwrap ( $res) |
Get the underlying RDBMS driver-specific result resource. | |
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(). | |
Private Attributes | |
string[] null | $fieldNames |
Cache of field names. | |
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 23 of file ResultWrapper.php.
Wikimedia\Rdbms\ResultWrapper::count | ( | ) |
Get the number of rows in a result object.
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 125 of file ResultWrapper.php.
Referenced by Wikimedia\Rdbms\FakeResultWrapper\doNumRows(), and Wikimedia\Rdbms\SqliteResultWrapper\doNumRows().
Wikimedia\Rdbms\ResultWrapper::current | ( | ) |
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 166 of file ResultWrapper.php.
|
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.
|
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.
|
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.
|
abstractprotected |
Get the field names in the result set.
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper, Wikimedia\Rdbms\MysqliResultWrapper, Wikimedia\Rdbms\PostgresResultWrapper, and Wikimedia\Rdbms\SqliteResultWrapper.
|
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.
Referenced by Wikimedia\Rdbms\ResultWrapper\numRows().
|
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 129 of file ResultWrapper.php.
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 135 of file ResultWrapper.php.
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 156 of file ResultWrapper.php.
Wikimedia\Rdbms\ResultWrapper::getFieldNames | ( | ) |
Get the names of the fields in the result.
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 187 of file ResultWrapper.php.
Wikimedia\Rdbms\ResultWrapper::key | ( | ) |
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 174 of file ResultWrapper.php.
Wikimedia\Rdbms\ResultWrapper::next | ( | ) |
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 178 of file ResultWrapper.php.
Wikimedia\Rdbms\ResultWrapper::numRows | ( | ) |
Get the number of rows in a result object.
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 121 of file ResultWrapper.php.
References Wikimedia\Rdbms\ResultWrapper\doNumRows().
Wikimedia\Rdbms\ResultWrapper::rewind | ( | ) |
Definition at line 161 of file ResultWrapper.php.
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 141 of file ResultWrapper.php.
|
static |
Get the underlying RDBMS driver-specific result resource.
The result resource field should not be accessed from non-Database related classes. It is database class specific and is stored here to associate iterators with queries.
self | mixed | $res |
Definition at line 59 of file ResultWrapper.php.
References $res, and wfDeprecated().
Wikimedia\Rdbms\ResultWrapper::valid | ( | ) |
Definition at line 182 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 34 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 40 of file ResultWrapper.php.
|
private |
Cache of field names.
Definition at line 45 of file ResultWrapper.php.
|
protected |
The offset of the row that would be returned by the next call to fetchObject().
Definition at line 28 of file ResultWrapper.php.