MediaWiki
REL1_31
MssqlResultWrapper.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Wikimedia\Rdbms
;
4
5
use stdClass;
6
7
class
MssqlResultWrapper
extends
ResultWrapper
{
9
private
$seekTo
=
null
;
10
14
public
function
fetchObject
() {
15
$res
=
$this->result
;
16
17
if
( $this->seekTo !==
null
) {
18
$result = sqlsrv_fetch_object(
$res
, stdClass::class, [],
19
SQLSRV_SCROLL_ABSOLUTE, $this->seekTo );
20
$this->seekTo =
null
;
21
}
else
{
22
$result = sqlsrv_fetch_object(
$res
);
23
}
24
25
// Return boolean false when there are no more rows instead of null
26
if
( $result ===
null
) {
27
return
false
;
28
}
29
30
return
$result
;
31
}
32
36
public
function
fetchRow
() {
37
$res
=
$this->result
;
38
39
if
( $this->seekTo !==
null
) {
40
$result = sqlsrv_fetch_array(
$res
, SQLSRV_FETCH_BOTH,
41
SQLSRV_SCROLL_ABSOLUTE, $this->seekTo );
42
$this->seekTo =
null
;
43
}
else
{
44
$result = sqlsrv_fetch_array(
$res
);
45
}
46
47
// Return boolean false when there are no more rows instead of null
48
if
( $result ===
null
) {
49
return
false
;
50
}
51
52
return
$result
;
53
}
54
59
public
function
seek
( $row ) {
60
$res
=
$this->result
;
61
62
// check bounds
63
$numRows = $this->db->numRows(
$res
);
64
$row = intval( $row );
65
66
if
( $numRows === 0 ) {
67
return
false
;
68
} elseif ( $row < 0 || $row > $numRows - 1 ) {
69
return
false
;
70
}
71
72
// Unlike MySQL, the seek actually happens on the next access
73
$this->seekTo = $row;
74
return
true
;
75
}
76
}
Wikimedia\Rdbms\MssqlResultWrapper
Definition
MssqlResultWrapper.php:7
Wikimedia\Rdbms\MssqlResultWrapper\$seekTo
int null $seekTo
Definition
MssqlResultWrapper.php:9
Wikimedia\Rdbms\MssqlResultWrapper\seek
seek( $row)
Definition
MssqlResultWrapper.php:59
Wikimedia\Rdbms\MssqlResultWrapper\fetchRow
fetchRow()
Definition
MssqlResultWrapper.php:36
Wikimedia\Rdbms\MssqlResultWrapper\fetchObject
fetchObject()
Definition
MssqlResultWrapper.php:14
Wikimedia\Rdbms\ResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition
ResultWrapper.php:24
Wikimedia\Rdbms\ResultWrapper\$result
resource array null $result
Optional underlying result handle for subclass usage.
Definition
ResultWrapper.php:26
$res
$res
Definition
database.txt:21
Wikimedia\Rdbms
Definition
ChronologyProtector.php:24
includes
libs
rdbms
database
resultwrapper
MssqlResultWrapper.php
Generated on Mon Nov 25 2024 15:35:02 for MediaWiki by
1.10.0