00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 require_once 'creole/ResultSet.php';
00023 require_once 'creole/common/ResultSetCommon.php';
00024
00036 class SQLiteResultSet extends ResultSetCommon implements ResultSet {
00037
00042 public function getIterator()
00043 {
00044 require_once 'creole/drivers/sqlite/SQLiteResultSetIterator.php';
00045 return new SQLiteResultSetIterator($this);
00046 }
00047
00051 public function seek($rownum)
00052 {
00053
00054
00055 if (!@sqlite_seek($this->result, $rownum)) {
00056 return false;
00057 }
00058 $this->cursorPos = $rownum;
00059 return true;
00060 }
00061
00065 function next()
00066 {
00067 $this->fields = sqlite_fetch_array($this->result, $this->fetchmode);
00068 if (!$this->fields) {
00069 $errno = sqlite_last_error($this->conn->getResource());
00070 if (!$errno) {
00071
00072 $this->afterLast();
00073 return false;
00074 } else {
00075 throw new SQLException("Error fetching result", sqlite_error_string($errno));
00076 }
00077 }
00078
00079
00080 $this->cursorPos++;
00081 return true;
00082 }
00083
00087 public function getRecordCount()
00088 {
00089 $rows = @sqlite_num_rows($this->result);
00090 if ($rows === null) {
00091 throw new SQLException("Error fetching num rows", sqlite_error_string(sqlite_last_error($this->conn->getResource())));
00092 }
00093 return (int) $rows;
00094 }
00095
00100 public function getBlob($column)
00101 {
00102 $idx = (is_int($column) ? $column - 1 : $column);
00103 if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); }
00104 if ($this->fields[$idx] === null) { return null; }
00105 require_once 'creole/util/Blob.php';
00106 $b = new Blob();
00107 $b->setContents(sqlite_udf_decode_binary($this->fields[$idx]));
00108 return $b;
00109 }
00110
00115 public function close()
00116 {
00117 $this->fields = array();
00118 }
00119 }