MediaWiki REL1_30
|
Result wrapper for grabbing data queried from an IDatabase object. More...
Public Member Functions | |
__construct (IDatabase $db=null, $result) | |
Create a row iterator from a result resource and an optional Database 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. | |
key () | |
next () | |
numRows () | |
Get the number of rows in a result object. | |
rewind () | |
seek ( $row) | |
Change the position of the cursor in a result object. | |
valid () | |
Public Attributes | |
resource array null | $result |
Optional underlying result handle for subclass usage. | |
Protected Attributes | |
stdClass null | $currentRow = null |
IDatabase null | $db |
int | $pos = 0 |
Private Member Functions | |
getDB () | |
Result wrapper for grabbing data queried from an IDatabase object.
Note that using the Iterator methods in combination with the non-Iterator DB 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. If no database is provided, and the subclass does not override the DB iteration methods, then a RuntimeException will be thrown when iteration is attempted.
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.
Definition at line 24 of file ResultWrapper.php.
Wikimedia\Rdbms\ResultWrapper::__construct | ( | IDatabase | $db = null, |
$result ) |
Create a row iterator from a result resource and an optional Database object.
Only Database-related classes should construct ResultWrapper. Other code may use the FakeResultWrapper subclass for convenience or compatibility shims, however.
IDatabase | null | $db | Optional database handle |
ResultWrapper | array | resource | $result | Optional underlying result handle |
Definition at line 45 of file ResultWrapper.php.
References Wikimedia\Rdbms\ResultWrapper\$db, and Wikimedia\Rdbms\ResultWrapper\$result.
Wikimedia\Rdbms\ResultWrapper::current | ( | ) |
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 98 of file ResultWrapper.php.
References Wikimedia\Rdbms\ResultWrapper\$currentRow, and Wikimedia\Rdbms\ResultWrapper\next().
Referenced by Wikimedia\Rdbms\ResultWrapper\valid().
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.
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper, and Wikimedia\Rdbms\MssqlResultWrapper.
Definition at line 58 of file ResultWrapper.php.
References Wikimedia\Rdbms\ResultWrapper\getDB().
Referenced by Wikimedia\Rdbms\ResultWrapper\next().
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.
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper, and Wikimedia\Rdbms\MssqlResultWrapper.
Definition at line 62 of file ResultWrapper.php.
References Wikimedia\Rdbms\ResultWrapper\getDB().
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.
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper.
Definition at line 70 of file ResultWrapper.php.
|
private |
RuntimeException |
Definition at line 82 of file ResultWrapper.php.
References Wikimedia\Rdbms\ResultWrapper\$db.
Referenced by Wikimedia\Rdbms\ResultWrapper\fetchObject(), Wikimedia\Rdbms\ResultWrapper\fetchRow(), Wikimedia\Rdbms\ResultWrapper\numRows(), Wikimedia\Rdbms\ResultWrapper\rewind(), and Wikimedia\Rdbms\ResultWrapper\seek().
Wikimedia\Rdbms\ResultWrapper::key | ( | ) |
Implements Wikimedia\Rdbms\IResultWrapper.
Definition at line 106 of file ResultWrapper.php.
References Wikimedia\Rdbms\ResultWrapper\$pos.
Wikimedia\Rdbms\ResultWrapper::next | ( | ) |
Implements Wikimedia\Rdbms\IResultWrapper.
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper.
Definition at line 110 of file ResultWrapper.php.
References Wikimedia\Rdbms\ResultWrapper\$currentRow, and Wikimedia\Rdbms\ResultWrapper\fetchObject().
Referenced by Wikimedia\Rdbms\ResultWrapper\current().
Wikimedia\Rdbms\ResultWrapper::numRows | ( | ) |
Get the number of rows in a result object.
Implements Wikimedia\Rdbms\IResultWrapper.
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper.
Definition at line 54 of file ResultWrapper.php.
References Wikimedia\Rdbms\ResultWrapper\getDB().
Referenced by Wikimedia\Rdbms\ResultWrapper\rewind().
Wikimedia\Rdbms\ResultWrapper::rewind | ( | ) |
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper.
Definition at line 90 of file ResultWrapper.php.
References Wikimedia\Rdbms\ResultWrapper\getDB(), and Wikimedia\Rdbms\ResultWrapper\numRows().
Wikimedia\Rdbms\ResultWrapper::seek | ( | $row | ) |
Change the position of the cursor in a result object.
See mysql_data_seek()
int | $row |
Implements Wikimedia\Rdbms\IResultWrapper.
Reimplemented in Wikimedia\Rdbms\FakeResultWrapper, and Wikimedia\Rdbms\MssqlResultWrapper.
Definition at line 66 of file ResultWrapper.php.
References Wikimedia\Rdbms\ResultWrapper\getDB().
Wikimedia\Rdbms\ResultWrapper::valid | ( | ) |
Definition at line 117 of file ResultWrapper.php.
References Wikimedia\Rdbms\ResultWrapper\current().
|
protected |
Definition at line 34 of file ResultWrapper.php.
Referenced by Wikimedia\Rdbms\ResultWrapper\current(), Wikimedia\Rdbms\FakeResultWrapper\fetchObject(), Wikimedia\Rdbms\FakeResultWrapper\fetchRow(), and Wikimedia\Rdbms\ResultWrapper\next().
|
protected |
Definition at line 29 of file ResultWrapper.php.
Referenced by Wikimedia\Rdbms\ResultWrapper\__construct(), and Wikimedia\Rdbms\ResultWrapper\getDB().
|
protected |
Definition at line 32 of file ResultWrapper.php.
Referenced by Wikimedia\Rdbms\FakeResultWrapper\fetchRow(), and Wikimedia\Rdbms\ResultWrapper\key().
resource array null Wikimedia\Rdbms\ResultWrapper::$result |
Optional underlying result handle for subclass usage.
Definition at line 26 of file ResultWrapper.php.
Referenced by Wikimedia\Rdbms\ResultWrapper\__construct(), Wikimedia\Rdbms\MssqlResultWrapper\fetchObject(), Wikimedia\Rdbms\MssqlResultWrapper\fetchRow(), and Wikimedia\Rdbms\MssqlResultWrapper\seek().