Manual:IResultWrapper.php
MediaWiki file: IResultWrapper.php | |
---|---|
Location: | includes/libs/rdbms/database/resultwrapper/ |
Source code: | master • 1.43.1 • 1.42.6 • 1.39.12 |
Classes: | Wikimedia\Rdbms\IResultWrapper |
PHP interface of a result wrapper for grabbing data queried from an IDatabase object.
Extends
Implemented by
e.g.
Usage notes
- By default, this will use the iteration methods of the IDatabase handle if provided.
- Using the Iterator methods in combination with the non-Iterator DB result iteration functions may cause rows to be skipped or repeated.
- 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.
Methods
- numRows() - get the number of rows in a result object
- count() - get the number of rows in a result object
- 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. - seek( $pos ) - Change the position of the cursor in a result object. See
mysql_data_seek()
. - 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.
- current()
- key()
- next()
- getFieldNames() - get the names of the fields in the result