Public Member Functions | |
__construct (Connection $conn, $result, $fetchmode=null) | |
Constructor. | |
__destruct () | |
Destructor. | |
getIterator () | |
getResource () | |
isLowerAssocCase () | |
setFetchmode ($mode) | |
getFetchmode () | |
previous () | |
relative ($offset) | |
absolute ($pos) | |
first () | |
last () | |
beforeFirst () | |
afterLast () | |
isAfterLast () | |
isBeforeFirst () | |
getCursorPos () | |
getRow () | |
get ($column) | |
getArray ($column) | |
getBoolean ($column) | |
getBlob ($column) | |
getClob ($column) | |
getDate ($column, $format= '%x') | |
getFloat ($column) | |
getInt ($column) | |
getString ($column) | |
getTime ($column, $format= '%X') | |
getTimestamp ($column, $format= 'Y-m-d H:i:s') | |
Protected Attributes | |
$fetchmode | |
$conn | |
$result | |
$cursorPos = 0 | |
$fields | |
$lowerAssocCase = false | |
$rtrimString = false |
Definition at line 53 of file ResultSetCommon.php.
ResultSetCommon::__construct | ( | Connection $ | conn, | |
$ | result, | |||
$ | fetchmode = null | |||
) |
Constructor.
Reimplemented in ODBCResultSet, and ODBCResultSetCommon.
Definition at line 100 of file ResultSetCommon.php.
References $fetchmode, $result, Creole::COMPAT_ASSOC_LOWER, Creole::COMPAT_RTRIM_STRING, ResultSet::FETCHMODE_ASSOC, and Connection::getFlags().
00101 { 00102 $this->conn = $conn; 00103 $this->result = $result; 00104 if ($fetchmode !== null) { 00105 $this->fetchmode = $fetchmode; 00106 } else { 00107 $this->fetchmode = ResultSet::FETCHMODE_ASSOC; // default 00108 } 00109 $this->lowerAssocCase = (($conn->getFlags() & Creole::COMPAT_ASSOC_LOWER) === Creole::COMPAT_ASSOC_LOWER); 00110 $this->rtrimString = (($conn->getFlags() & Creole::COMPAT_RTRIM_STRING) === Creole::COMPAT_RTRIM_STRING); 00111 }
ResultSetCommon::__destruct | ( | ) |
ResultSetCommon::absolute | ( | $ | pos | ) |
Definition at line 203 of file ResultSetCommon.php.
References afterLast(), and beforeFirst().
00204 { 00205 $ok = $this->seek( $pos - 1 ); // compensate for next() factor 00206 if ($ok === false) { 00207 if ($pos - 1 < 0) { 00208 $this->beforeFirst(); 00209 } else { 00210 $this->afterLast(); 00211 } 00212 } else { 00213 $ok = $this->next(); 00214 } 00215 return $ok; 00216 }
ResultSetCommon::afterLast | ( | ) |
Definition at line 249 of file ResultSetCommon.php.
Referenced by absolute(), SQLiteResultSet::next(), PgSQLResultSet::next(), OCI8ResultSet::next(), MySQLiResultSet::next(), MySQLResultSet::next(), MSSQLResultSet::next(), and relative().
ResultSetCommon::beforeFirst | ( | ) |
Definition at line 241 of file ResultSetCommon.php.
Referenced by absolute(), previous(), and relative().
ResultSetCommon::first | ( | ) |
ResultSetCommon::get | ( | $ | column | ) |
Definition at line 289 of file ResultSetCommon.php.
00290 { 00291 $idx = (is_int($column) ? $column - 1 : $column); 00292 if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); } 00293 return $this->fields[$idx]; 00294 }
ResultSetCommon::getArray | ( | $ | column | ) |
Reimplemented in PgSQLResultSet.
Definition at line 299 of file ResultSetCommon.php.
00300 { 00301 $idx = (is_int($column) ? $column - 1 : $column); 00302 if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); } 00303 if ($this->fields[$idx] === null) { return null; } 00304 return (array) unserialize($this->fields[$idx]); 00305 }
ResultSetCommon::getBlob | ( | $ | column | ) |
Reimplemented in ODBCResultSet, PgSQLResultSet, and SQLiteResultSet.
Definition at line 321 of file ResultSetCommon.php.
00322 { 00323 $idx = (is_int($column) ? $column - 1 : $column); 00324 if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); } 00325 if ($this->fields[$idx] === null) { return null; } 00326 require_once 'creole/util/Blob.php'; 00327 $b = new Blob(); 00328 $b->setContents($this->fields[$idx]); 00329 return $b; 00330 }
ResultSetCommon::getBoolean | ( | $ | column | ) |
Reimplemented in PgSQLResultSet.
Definition at line 310 of file ResultSetCommon.php.
00311 { 00312 $idx = (is_int($column) ? $column - 1 : $column); 00313 if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); } 00314 if ($this->fields[$idx] === null) { return null; } 00315 return (boolean) $this->fields[$idx]; 00316 }
ResultSetCommon::getClob | ( | $ | column | ) |
Reimplemented in ODBCResultSet.
Definition at line 335 of file ResultSetCommon.php.
00336 { 00337 $idx = (is_int($column) ? $column - 1 : $column); 00338 if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); } 00339 if ($this->fields[$idx] === null) { return null; } 00340 require_once 'creole/util/Clob.php'; 00341 $c = new Clob(); 00342 $c->setContents($this->fields[$idx]); 00343 return $c; 00344 }
ResultSetCommon::getCursorPos | ( | ) |
ResultSetCommon::getDate | ( | $ | column, | |
$ | format = '%x' | |||
) |
Definition at line 349 of file ResultSetCommon.php.
00350 { 00351 $idx = (is_int($column) ? $column - 1 : $column); 00352 if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); } 00353 if ($this->fields[$idx] === null) { return null; } 00354 $ts = strtotime($this->fields[$idx]); 00355 if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 00356 throw new SQLException("Unable to convert value at column " . $column . " to timestamp: " . $this->fields[$idx]); 00357 } 00358 if ($format === null) { 00359 return $ts; 00360 } 00361 if (strpos($format, '%') !== false) { 00362 return strftime($format, $ts); 00363 } else { 00364 return date($format, $ts); 00365 } 00366 }
ResultSetCommon::getFetchmode | ( | ) |
Definition at line 159 of file ResultSetCommon.php.
Referenced by SQLiteResultSetIterator::__construct(), and PgSQLResultSetIterator::__construct().
ResultSetCommon::getFloat | ( | $ | column | ) |
Definition at line 371 of file ResultSetCommon.php.
00372 { 00373 $idx = (is_int($column) ? $column - 1 : $column); 00374 if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); } 00375 if ($this->fields[$idx] === null) { return null; } 00376 return (float) $this->fields[$idx]; 00377 }
ResultSetCommon::getInt | ( | $ | column | ) |
Definition at line 382 of file ResultSetCommon.php.
00383 { 00384 $idx = (is_int($column) ? $column - 1 : $column); 00385 if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); } 00386 if ($this->fields[$idx] === null) { return null; } 00387 return (int) $this->fields[$idx]; 00388 }
ResultSetCommon::getIterator | ( | ) |
Reimplemented in SQLiteResultSet.
Definition at line 126 of file ResultSetCommon.php.
00127 { 00128 require_once 'creole/ResultSetIterator.php'; 00129 return new ResultSetIterator($this); 00130 }
ResultSetCommon::getResource | ( | ) |
Definition at line 135 of file ResultSetCommon.php.
Referenced by SQLiteResultSetIterator::__construct(), and PgSQLResultSetIterator::__construct().
ResultSetCommon::getRow | ( | ) |
ResultSetCommon::getString | ( | $ | column | ) |
Reimplemented in MySQLResultSet, and MySQLiResultSet.
Definition at line 393 of file ResultSetCommon.php.
00394 { 00395 $idx = (is_int($column) ? $column - 1 : $column); 00396 if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); } 00397 if ($this->fields[$idx] === null) { return null; } 00398 return ($this->rtrimString ? rtrim($this->fields[$idx]) : (string) $this->fields[$idx]); 00399 }
ResultSetCommon::getTime | ( | $ | column, | |
$ | format = '%X' | |||
) |
Definition at line 404 of file ResultSetCommon.php.
00405 { 00406 $idx = (is_int($column) ? $column - 1 : $column); 00407 if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); } 00408 if ($this->fields[$idx] === null) { return null; } 00409 00410 $ts = strtotime($this->fields[$idx]); 00411 00412 if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 00413 throw new SQLException("Unable to convert value at column " . (is_int($column) ? $column + 1 : $column) . " to timestamp: " . $this->fields[$idx]); 00414 } 00415 if ($format === null) { 00416 return $ts; 00417 } 00418 if (strpos($format, '%') !== false) { 00419 return strftime($format, $ts); 00420 } else { 00421 return date($format, $ts); 00422 } 00423 }
ResultSetCommon::getTimestamp | ( | $ | column, | |
$ | format = 'Y-m-d H:i:s' | |||
) |
Reimplemented in MySQLResultSet, and MySQLiResultSet.
Definition at line 428 of file ResultSetCommon.php.
00428 :i:s') 00429 { 00430 $idx = (is_int($column) ? $column - 1 : $column); 00431 if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); } 00432 if ($this->fields[$idx] === null) { return null; } 00433 00434 $ts = strtotime($this->fields[$idx]); 00435 if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 00436 throw new SQLException("Unable to convert value at column " . $column . " to timestamp: " . $this->fields[$idx]); 00437 } 00438 if ($format === null) { 00439 return $ts; 00440 } 00441 if (strpos($format, '%') !== false) { 00442 return strftime($format, $ts); 00443 } else { 00444 return date($format, $ts); 00445 } 00446 }
ResultSetCommon::isAfterLast | ( | ) |
Reimplemented in ODBCCachedResultSet, and ODBCResultSet.
Definition at line 257 of file ResultSetCommon.php.
ResultSetCommon::isBeforeFirst | ( | ) |
ResultSetCommon::isLowerAssocCase | ( | ) |
ResultSetCommon::last | ( | ) |
Definition at line 230 of file ResultSetCommon.php.
00231 { 00232 if($this->cursorPos !== ($last = $this->getRecordCount() - 1)) { 00233 $this->seek( $last ); 00234 } 00235 return $this->next(); 00236 }
ResultSetCommon::previous | ( | ) |
Definition at line 167 of file ResultSetCommon.php.
References beforeFirst().
00168 { 00169 // Go back 2 spaces so that we can then advance 1 space. 00170 $ok = $this->seek($this->cursorPos - 2); 00171 if ($ok === false) { 00172 $this->beforeFirst(); 00173 return false; 00174 } 00175 return $this->next(); 00176 }
ResultSetCommon::relative | ( | $ | offset | ) |
Definition at line 181 of file ResultSetCommon.php.
References afterLast(), and beforeFirst().
00182 { 00183 // which absolute row number are we seeking 00184 $pos = $this->cursorPos + ($offset - 1); 00185 $ok = $this->seek($pos); 00186 00187 if ($ok === false) { 00188 if ($pos < 0) { 00189 $this->beforeFirst(); 00190 } else { 00191 $this->afterLast(); 00192 } 00193 } else { 00194 $ok = $this->next(); 00195 } 00196 00197 return $ok; 00198 }
ResultSetCommon::setFetchmode | ( | $ | mode | ) |
ResultSetCommon::$conn [protected] |
Definition at line 65 of file ResultSetCommon.php.
ResultSetCommon::$cursorPos = 0 [protected] |
Definition at line 77 of file ResultSetCommon.php.
ResultSetCommon::$fetchmode [protected] |
Definition at line 59 of file ResultSetCommon.php.
Referenced by ODBCResultSetCommon::__construct(), ODBCResultSet::__construct(), ODBCCachedResultSet::__construct(), and __construct().
ResultSetCommon::$fields [protected] |
ResultSetCommon::$lowerAssocCase = false [protected] |
Definition at line 89 of file ResultSetCommon.php.
ResultSetCommon::$result [protected] |
Definition at line 71 of file ResultSetCommon.php.
Referenced by ODBCResultSetCommon::__construct(), ODBCResultSet::__construct(), ODBCCachedResultSet::__construct(), __construct(), and ODBCCachedResultSet::loadCache().
ResultSetCommon::$rtrimString = false [protected] |
Definition at line 95 of file ResultSetCommon.php.