3 namespace Wikimedia\Rdbms
;
6 use OutOfBoundsException
;
11 * Result wrapper for grabbing data queried from an IDatabase object
13 * Note that using the Iterator methods in combination with the non-Iterator
14 * DB result iteration functions may cause rows to be skipped or repeated.
16 * By default, this will use the iteration methods of the IDatabase handle if provided.
17 * Subclasses can override methods to make it solely work on the result resource instead.
18 * If no database is provided, and the subclass does not override the DB iteration methods,
19 * then a RuntimeException will be thrown when iteration is attempted.
21 * The result resource field should not be accessed from non-Database related classes.
22 * It is database class specific and is stored here to associate iterators with queries.
26 interface IResultWrapper
extends Countable
, SeekableIterator
{
28 * Get the number of rows in a result object
32 public function numRows();
35 * Get the number of rows in a result object
39 public function count(): int;
42 * Fetch the next row from the given result object, in object form. Fields can be retrieved with
43 * $row->fieldname, with fields acting like member variables. If no more rows are available,
46 * @return stdClass|false
47 * @throws DBUnexpectedError Thrown if the database returns an error
49 public function fetchObject();
52 * Fetch the next row from the given result object, in associative array form. Fields are
53 * retrieved with $row['fieldname']. If no more rows are available, false is returned.
56 * @throws DBUnexpectedError Thrown if the database returns an error
58 public function fetchRow();
61 * Change the position of the cursor in a result object.
62 * See mysql_data_seek()
64 * @throws OutOfBoundsException
67 public function seek( $pos ): void
;
70 * Free a result object
72 * This either saves memory in PHP (buffered queries) or on the server (unbuffered queries).
73 * In general, queries are not large enough in result sets for this to be worth calling.
75 public function free();
78 * @return stdClass|array|false
80 #[\ReturnTypeWillChange]
81 public function current();
86 public function key(): int;
91 public function next(): void
;
94 * Get the names of the fields in the result
99 public function getFieldNames();