Merge "Add support for PHP7 random_bytes in favor of mcrypt_create_iv"
[lhc/web/wiklou.git] / includes / libs / rdbms / database / resultwrapper / IResultWrapper.php
1 <?php
2
3 namespace Wikimedia\Rdbms;
4
5 use Iterator;
6 use DBUnexpectedError;
7 use stdClass;
8
9 /**
10 * Result wrapper for grabbing data queried from an IDatabase object
11 *
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.
14 *
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.
19 *
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.
22 *
23 * @ingroup Database
24 */
25 interface IResultWrapper extends Iterator {
26 /**
27 * Get the number of rows in a result object
28 *
29 * @return int
30 */
31 public function numRows();
32
33 /**
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,
36 * false is returned.
37 *
38 * @return stdClass|bool
39 * @throws DBUnexpectedError Thrown if the database returns an error
40 */
41 public function fetchObject();
42
43 /**
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.
46 *
47 * @return array|bool
48 * @throws DBUnexpectedError Thrown if the database returns an error
49 */
50 public function fetchRow();
51
52 /**
53 * Change the position of the cursor in a result object.
54 * See mysql_data_seek()
55 *
56 * @param int $row
57 */
58 public function seek( $row );
59
60 /**
61 * Free a result object
62 *
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.
65 */
66 public function free();
67
68 /**
69 * @return stdClass|array|bool
70 */
71 public function current();
72
73 /**
74 * @return int
75 */
76 public function key();
77
78 /**
79 * @return stdClass
80 */
81 function next();
82 }