3 namespace Wikimedia\Rdbms
;
10 * Result wrapper for grabbing data queried from an IDatabase object
12 * Note that using the Iterator methods in combination with the non-Iterator
13 * DB result iteration functions may cause rows to be skipped or repeated.
15 * By default, this will use the iteration methods of the IDatabase handle if provided.
16 * Subclasses can override methods to make it solely work on the result resource instead.
17 * If no database is provided, and the subclass does not override the DB iteration methods,
18 * then a RuntimeException will be thrown when iteration is attempted.
20 * The result resource field should not be accessed from non-Database related classes.
21 * It is database class specific and is stored here to associate iterators with queries.
25 interface IResultWrapper
extends Iterator
{
27 * Get the number of rows in a result object
31 public function numRows();
34 * Fetch the next row from the given result object, in object form. Fields can be retrieved with
35 * $row->fieldname, with fields acting like member variables. If no more rows are available,
38 * @return stdClass|bool
39 * @throws DBUnexpectedError Thrown if the database returns an error
41 public function fetchObject();
44 * Fetch the next row from the given result object, in associative array form. Fields are
45 * retrieved with $row['fieldname']. If no more rows are available, false is returned.
48 * @throws DBUnexpectedError Thrown if the database returns an error
50 public function fetchRow();
53 * Change the position of the cursor in a result object.
54 * See mysql_data_seek()
58 public function seek( $row );
61 * Free a result object
63 * This either saves memory in PHP (buffered queries) or on the server (unbuffered queries).
64 * In general, queries are not large enough in result sets for this to be worth calling.
66 public function free();
69 * @return stdClass|array|bool
71 public function current();
76 public function key();