3 namespace Wikimedia\Rdbms
;
7 class MssqlResultWrapper
extends ResultWrapper
{
8 /** @var integer|null */
9 private $mSeekTo = null;
12 * @return stdClass|bool
14 public function fetchObject() {
17 if ( $this->mSeekTo
!== null ) {
18 $result = sqlsrv_fetch_object( $res, 'stdClass', [],
19 SQLSRV_SCROLL_ABSOLUTE
, $this->mSeekTo
);
20 $this->mSeekTo
= null;
22 $result = sqlsrv_fetch_object( $res );
25 // Return boolean false when there are no more rows instead of null
26 if ( $result === null ) {
36 public function fetchRow() {
39 if ( $this->mSeekTo
!== null ) {
40 $result = sqlsrv_fetch_array( $res, SQLSRV_FETCH_BOTH
,
41 SQLSRV_SCROLL_ABSOLUTE
, $this->mSeekTo
);
42 $this->mSeekTo
= null;
44 $result = sqlsrv_fetch_array( $res );
47 // Return boolean false when there are no more rows instead of null
48 if ( $result === null ) {
59 public function seek( $row ) {
63 $numRows = $this->db
->numRows( $res );
64 $row = intval( $row );
66 if ( $numRows === 0 ) {
68 } elseif ( $row < 0 ||
$row > $numRows - 1 ) {
72 // Unlike MySQL, the seek actually happens on the next access
73 $this->mSeekTo
= $row;