blob: 12e59b598f624c6652d9dae876a099cbe71d9174 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<?php
namespace Wikimedia\Rdbms;
use stdClass;
/**
* Overloads the relevant methods of the real ResultsWrapper so it
* doesn't go anywhere near an actual database.
*/
class FakeResultWrapper extends ResultWrapper {
/** @var stdClass[] $result */
/**
* @param stdClass[] $rows
*/
function __construct( array $rows ) {
parent::__construct( null, $rows );
}
function numRows() {
return count( $this->result );
}
function fetchRow() {
if ( $this->pos < count( $this->result ) ) {
$this->currentRow = $this->result[$this->pos];
} else {
$this->currentRow = false;
}
$this->pos++;
if ( is_object( $this->currentRow ) ) {
return get_object_vars( $this->currentRow );
} else {
return $this->currentRow;
}
}
function seek( $row ) {
$this->pos = $row;
}
function free() {
}
function fetchObject() {
$this->fetchRow();
if ( $this->currentRow ) {
return (object)$this->currentRow;
} else {
return false;
}
}
function rewind() {
$this->pos = 0;
$this->currentRow = null;
}
function next() {
return $this->fetchObject();
}
}
class_alias( FakeResultWrapper::class, 'FakeResultWrapper' );
|