Public Member Functions | |
_setOffset ($offset) | |
This MSSQL-only function exists to set offset after ResultSet is instantiated. | |
_setLimit ($limit) | |
This MSSQL-only function exists to set limit after ResultSet is instantiated. | |
seek ($rownum) | |
next () | |
getRecordCount () | |
close () | |
Private Attributes | |
$offset = 0 | |
$limit = 0 |
Definition at line 36 of file MSSQLResultSet.php.
MSSQLResultSet::_setLimit | ( | $ | limit | ) |
This MSSQL-only function exists to set limit after ResultSet is instantiated.
This function should be "protected" in Java sense: only available to classes in package. THIS METHOD SHOULD NOT BE CALLED BY ANYTHING EXCEPTION DRIVER CLASSES.
int | $limit New limit. protected |
Definition at line 72 of file MSSQLResultSet.php.
References $limit.
00073 { 00074 $this->limit = $limit; 00075 }
MSSQLResultSet::_setOffset | ( | $ | offset | ) |
This MSSQL-only function exists to set offset after ResultSet is instantiated.
This function should be "protected" in Java sense: only available to classes in package. THIS METHOD SHOULD NOT BE CALLED BY ANYTHING EXCEPTION DRIVER CLASSES.
int | $offset New offset. If great than 0, then seek(0) will be called to move cursor. protected |
Definition at line 57 of file MSSQLResultSet.php.
References $offset, and seek().
00058 { 00059 $this->offset = $offset; 00060 if ($offset > 0) { 00061 $this->seek(0); // 0 becomes $offset by seek() method 00062 } 00063 }
MSSQLResultSet::close | ( | ) |
Implements ResultSet.
Definition at line 150 of file MSSQLResultSet.php.
00151 { 00152 $ret = @mssql_free_result($this->result); 00153 $this->result = false; 00154 $this->fields = array(); 00155 $this->limit = 0; 00156 $this->offset = 0; 00157 }
MSSQLResultSet::getRecordCount | ( | ) |
Implements ResultSet.
Definition at line 136 of file MSSQLResultSet.php.
00137 { 00138 $rows = @mssql_num_rows($this->result); 00139 if ($rows === null) { 00140 throw new SQLException('Error getting record count', mssql_get_last_message()); 00141 } 00142 // adjust count based on emulated LIMIT/OFFSET 00143 $rows -= $this->offset; 00144 return ($this->limit > 0 && $rows > $this->limit ? $this->limit : $rows); 00145 }
MSSQLResultSet::next | ( | ) |
Implements ResultSet.
Definition at line 104 of file MSSQLResultSet.php.
References ResultSetCommon::afterLast(), and ResultSet::FETCHMODE_ASSOC.
00105 { 00106 // support emulated LIMIT 00107 if ( $this->limit > 0 && ($this->cursorPos >= $this->limit) ) { 00108 $this->afterLast(); 00109 return false; 00110 } 00111 00112 $this->fields = mssql_fetch_array($this->result, $this->fetchmode); 00113 00114 if (!$this->fields) { 00115 if ($errmsg = mssql_get_last_message()) { 00116 throw new SQLException("Error fetching result", $errmsg); 00117 } else { 00118 // We've advanced beyond end of recordset. 00119 $this->afterLast(); 00120 return false; 00121 } 00122 } 00123 00124 if ($this->fetchmode === ResultSet::FETCHMODE_ASSOC && $this->lowerAssocCase) { 00125 $this->fields = array_change_key_case($this->fields, CASE_LOWER); 00126 } 00127 00128 // Advance cursor position 00129 $this->cursorPos++; 00130 return true; 00131 }
MSSQLResultSet::seek | ( | $ | rownum | ) |
Implements ResultSet.
Definition at line 80 of file MSSQLResultSet.php.
Referenced by _setOffset().
00081 { 00082 // support emulated OFFSET 00083 $actual = $rownum + $this->offset; 00084 00085 if (($this->limit > 0 && $rownum >= $this->limit) || $rownum < 0) { 00086 // have to check for rownum < 0, because mssql_seek() won't 00087 // complain if the $actual is valid. 00088 return false; 00089 } 00090 00091 // MSSQL rows start w/ 0, but this works, because we are 00092 // looking to move the position _before_ the next desired position 00093 if (!@mssql_data_seek($this->result, $actual)) { 00094 return false; 00095 } 00096 00097 $this->cursorPos = $rownum; 00098 return true; 00099 }
MSSQLResultSet::$limit = 0 [private] |
MSSQLResultSet::$offset = 0 [private] |