Merge "Perform a permission check on the title when changing the page language"
[lhc/web/wiklou.git] / includes / libs / rdbms / database / resultwrapper / IResultWrapper.php
1 <?php
2
3 namespace Wikimedia\Rdbms;
4
5 use Iterator;
6 use stdClass;
7
8 /**
9 * Result wrapper for grabbing data queried from an IDatabase object
10 *
11 * Note that using the Iterator methods in combination with the non-Iterator
12 * DB result iteration functions may cause rows to be skipped or repeated.
13 *
14 * By default, this will use the iteration methods of the IDatabase handle if provided.
15 * Subclasses can override methods to make it solely work on the result resource instead.
16 * If no database is provided, and the subclass does not override the DB iteration methods,
17 * then a RuntimeException will be thrown when iteration is attempted.
18 *
19 * The result resource field should not be accessed from non-Database related classes.
20 * It is database class specific and is stored here to associate iterators with queries.
21 *
22 * @ingroup Database
23 */
24 interface IResultWrapper extends Iterator {
25 /**
26 * Get the number of rows in a result object
27 *
28 * @return int
29 */
30 public function numRows();
31
32 /**
33 * Fetch the next row from the given result object, in object form. Fields can be retrieved with
34 * $row->fieldname, with fields acting like member variables. If no more rows are available,
35 * false is returned.
36 *
37 * @return stdClass|bool
38 * @throws DBUnexpectedError Thrown if the database returns an error
39 */
40 public function fetchObject();
41
42 /**
43 * Fetch the next row from the given result object, in associative array form. Fields are
44 * retrieved with $row['fieldname']. If no more rows are available, false is returned.
45 *
46 * @return array|bool
47 * @throws DBUnexpectedError Thrown if the database returns an error
48 */
49 public function fetchRow();
50
51 /**
52 * Change the position of the cursor in a result object.
53 * See mysql_data_seek()
54 *
55 * @param int $row
56 */
57 public function seek( $row );
58
59 /**
60 * Free a result object
61 *
62 * This either saves memory in PHP (buffered queries) or on the server (unbuffered queries).
63 * In general, queries are not large enough in result sets for this to be worth calling.
64 */
65 public function free();
66
67 /**
68 * @return stdClass|array|bool
69 */
70 public function current();
71
72 /**
73 * @return int
74 */
75 public function key();
76
77 /**
78 * @return stdClass
79 */
80 function next();
81 }