Added release notes for 'ContentHandler::runLegacyHooks' removal
[mediawiki.git] / includes / libs / rdbms / database / resultwrapper / MssqlResultWrapper.php
blobb591f4f389cbbb80d6dedc441fbfcce5073334c0
1 <?php
2 class MssqlResultWrapper extends ResultWrapper {
3 /** @var integer|null */
4 private $mSeekTo = null;
6 /**
7 * @return stdClass|bool
8 */
9 public function fetchObject() {
10 $res = $this->result;
12 if ( $this->mSeekTo !== null ) {
13 $result = sqlsrv_fetch_object( $res, 'stdClass', [],
14 SQLSRV_SCROLL_ABSOLUTE, $this->mSeekTo );
15 $this->mSeekTo = null;
16 } else {
17 $result = sqlsrv_fetch_object( $res );
20 // Return boolean false when there are no more rows instead of null
21 if ( $result === null ) {
22 return false;
25 return $result;
28 /**
29 * @return array|bool
31 public function fetchRow() {
32 $res = $this->result;
34 if ( $this->mSeekTo !== null ) {
35 $result = sqlsrv_fetch_array( $res, SQLSRV_FETCH_BOTH,
36 SQLSRV_SCROLL_ABSOLUTE, $this->mSeekTo );
37 $this->mSeekTo = null;
38 } else {
39 $result = sqlsrv_fetch_array( $res );
42 // Return boolean false when there are no more rows instead of null
43 if ( $result === null ) {
44 return false;
47 return $result;
50 /**
51 * @param int $row
52 * @return bool
54 public function seek( $row ) {
55 $res = $this->result;
57 // check bounds
58 $numRows = $this->db->numRows( $res );
59 $row = intval( $row );
61 if ( $numRows === 0 ) {
62 return false;
63 } elseif ( $row < 0 || $row > $numRows - 1 ) {
64 return false;
67 // Unlike MySQL, the seek actually happens on the next access
68 $this->mSeekTo = $row;
69 return true;