/** * Internal method to fetch the next row in a result set * * @return Array Returns the field values */ public function fetch() { $current = sqlite_current($this->result, SQLITE_ASSOC); if (sqlite_valid($this->result)) { sqlite_next($this->result); } return $current ?: NULL; }
function result($query_id = 0, $row = 0, $field = NULL) { if ($query_id) { if ($row != 0) { @sqlite_seek($query_id, $row); } return @current(@sqlite_current($query_id)); } else { return false; } }
<pre> <?php $db = sqlite_open(dirname(__FILE__) . "/db.sqlite"); $res = sqlite_query("SELECT login FROM auth_tbl", $db); /* got rows? */ while (sqlite_has_more($res)) { /* fetch one row */ print_r(sqlite_current($res, SQLITE_ASSOC)); /* move along */ sqlite_next($res); } sqlite_close($db); ?> </pre>
function result($query_id = 0, $row = 0, $col = 0) { if ($query_id) { if ($row !== 0 && @sqlite_seek($query_id, $row) === false) { return false; } $cur_row = @sqlite_current($query_id); if ($cur_row === false) { return false; } return $cur_row[$col]; } else { return false; } }
public function current() { return $this->class->newInstance(sqlite_current($this->result)); }
function sqlitem_current($stmt, $result_type = SQLITE_BOTH, $decode_binary = TRUE) { $res = sqlitem_fetch_array($stmt, $result_type, $decode_binary); // $stmt-> return sqlite_current($result, $result_type, $decode_binary); }
function sqlitem_current($result, $result_type = SQLITE_BOTH, $decode_binary = TRUE) { return sqlite_current($result, $result_type, $decode_binary); }
} echo "num fields: " . sqlite_num_fields($r) . "\n"; for ($i = 0; $i < sqlite_num_fields($r); $i++) { var_dump(sqlite_field_name($r, $i)); } sqlite_exec("DROP TABLE strings", $db); ///// $data = array(array(0 => 'one', 1 => 'two'), array(0 => 'three', 1 => 'four')); sqlite_query("CREATE TABLE strings(a VARCHAR, b VARCHAR)", $db); foreach ($data as $str) { sqlite_query("INSERT INTO strings VALUES('{$str[0]}','{$str[1]}')", $db); } echo "====BUFFERED====\n"; $r = sqlite_query("SELECT a, b from strings", $db); while (sqlite_valid($r)) { var_dump(sqlite_current($r, SQLITE_NUM)); var_dump(sqlite_column($r, 0)); var_dump(sqlite_column($r, 1)); var_dump(sqlite_column($r, 'a')); var_dump(sqlite_column($r, 'b')); sqlite_next($r); } /// XXX this doesn't match PHP5, but ours looks more correct?? /* echo "====UNBUFFERED====\n"; $r = sqlite_unbuffered_query("SELECT a, b from strings", $db); while (sqlite_valid($r)) { var_dump(sqlite_current($r, SQLITE_NUM)); var_dump(sqlite_column($r, 0)); var_dump(sqlite_column($r, 'b')); var_dump(sqlite_column($r, 1));
function result($query_id = 0, $row = 0, $col = 0) { if ($query_id) { if ($row != 0) { @sqlite_seek($query_id, $row); } $cur_row = @sqlite_current($query_id); return $cur_row[$col]; } else { return false; } }
function gettimessince($since) { //Returns the times of all threads since $since. if (isset($this->binfo)) { //echo "Binfo"; //Will there be cases where this will be called without binfo being set? if ($since != null) { $yay = $this->myquery("select time from " . THthreads_table . " where board=" . $this->binfo['id'] . " and time>=" . $since); } else { $yay = $this->myquery("select time from " . THthreads_table . " where board=" . $this->binfo['id']); } } else { //echo "No binfo"; if ($since != null) { $yay = $this->myresult("select time from " . THthreads_table . " where time>=" . $since); } else { $yay = $this->myresult("select time from " . THthreads_table); } } //array($wows); $wows = array(); echo "Row count: " . sqlite_num_rows($yay); while ($row = sqlite_current($yay)) { //var_dump($row); $wows[] = (int) $row[0]; } return $wows; }
/** * Select a portion of rowset * * @param int $index01 first row number * @param int $index02 last row number * @param string $type type of index * 'both', 'num' or 'assoc' * @access public * @return mixed */ function selectRows($index01, $index02 = null, $type = null) { if (isset($type)) { $this->_setType($type); } if ($this->_buffer) { if (isset($index01) && (empty($index02) || $index02 < $index01)) { if (@sqlite_seek($this->_result, $index01)) { return sqlite_current($this->_result, $this->_type, true); } } else { while (@sqlite_seek($this->_result, $index01) && $index01 <= $index02) { $rows[] = sqlite_current($this->_result, $this->_type, true); $index01++; } return $rows; } } else { $this->_showError('Query unbuffered: selectRows() is unavailable'); return false; } }
/** * Returns the row (assoc array) at current cursor pos. * @return array */ function current() { return sqlite_current($this->result, $this->fetchmode); }
<pre> <?php $db = sqlite_open(dirname(__FILE__) . "/db.sqlite"); $res = sqlite_query("SELECT login FROM auth_tbl", $db); /* got rows? */ while (sqlite_has_more($res)) { /* fetch one row */ print_r(sqlite_current($res, SQLITE_NUM)); /* move along */ sqlite_next($res); } sqlite_close($db); ?> </pre>
echo "valid?\n"; var_dump($b); // if (function_exists('sqlite_key')) // echo "on row: ".sqlite_key($rh)."\n"; } // seek sqlite_seek($rh, 3); $result = sqlite_current($rh); var_dump($result); // seek sqlite_seek($rh, 100); $result = sqlite_current($rh); var_dump($result); // prev loop while (sqlite_prev($rh)) { $result = sqlite_current($rh); var_dump($result); $b = sqlite_has_prev($rh); echo "has_prev?\n"; var_dump($b); // // if (function_exists('sqlite_key')) // echo "on row: ".sqlite_key($rh)."\n"; } // columns sqlite_seek($rh, 2); for ($i = 0; $i < sqlite_num_fields($rh); $i++) { $n = sqlite_field_name($rh, $i); $c = sqlite_column($rh, $i); var_dump($c); $c = sqlite_column($rh, $n);