Merge "Move up devunt's name to Developers"
[lhc/web/wiklou.git] / includes / libs / rdbms / database / resultwrapper / FakeResultWrapper.php
1 <?php
2 /**
3 * Overloads the relevant methods of the real ResultsWrapper so it
4 * doesn't go anywhere near an actual database.
5 */
6 class FakeResultWrapper extends ResultWrapper {
7 /** @var $result stdClass[] */
8
9 /**
10 * @param stdClass[] $rows
11 */
12 function __construct( array $rows ) {
13 parent::__construct( null, $rows );
14 }
15
16 function numRows() {
17 return count( $this->result );
18 }
19
20 function fetchRow() {
21 if ( $this->pos < count( $this->result ) ) {
22 $this->currentRow = $this->result[$this->pos];
23 } else {
24 $this->currentRow = false;
25 }
26 $this->pos++;
27 if ( is_object( $this->currentRow ) ) {
28 return get_object_vars( $this->currentRow );
29 } else {
30 return $this->currentRow;
31 }
32 }
33
34 function seek( $row ) {
35 $this->pos = $row;
36 }
37
38 function free() {
39 }
40
41 function fetchObject() {
42 $this->fetchRow();
43 if ( $this->currentRow ) {
44 return (object)$this->currentRow;
45 } else {
46 return false;
47 }
48 }
49
50 function rewind() {
51 $this->pos = 0;
52 $this->currentRow = null;
53 }
54
55 function next() {
56 return $this->fetchObject();
57 }
58 }