/** * Seek * * @param int offset * @return bool success * @throws rdbms.SQLException */ public function seek($offset) { if (!sqlite_seek($this->handle, $offset)) { throw new SQLException('Cannot seek to offset ' . $offset); } return TRUE; }
function rewind() { if (isset($this->queryId) && is_resource($this->queryId) && sqlite_num_rows($this->queryId)) { if (sqlite_seek($this->queryId, 0) === false) { $this->connection->_raiseError(); } } elseif (!$this->queryId) { $query = $this->query; if (is_array($this->sort_params)) { if (preg_match('~(?<=FROM).+\\s+ORDER\\s+BY\\s+~i', $query)) { $query .= ','; } else { $query .= ' ORDER BY '; } foreach ($this->sort_params as $field => $order) { $query .= $this->connection->quoteIdentifier($field) . " {$order},"; } $query = rtrim($query, ','); } if ($this->limit) { $query .= ' LIMIT ' . $this->limit . ' OFFSET ' . $this->offset; } $this->queryId = $this->connection->execute($query); } $this->key = 0; $this->next(); }
function reset() { if ($this->row > 0) { sqlite_seek($this->id, 0); } $this->row = -1; return TRUE; }
public function seek($offset) { if ($this->offsetExists($offset) && sqlite_seek($this->_result, $offset)) { $this->_current_row = $this->_internal_row = $offset; return true; } else { return false; } }
/** * @see ResultSet::seek() */ public function seek($rownum) { // MySQL rows start w/ 0, but this works, because we are // looking to move the position _before_ the next desired position if (!@sqlite_seek($this->result, $rownum)) { return false; } $this->cursorPos = $rownum; return true; }
public function seek($offset) { if ($this->offsetExists($offset) and sqlite_seek($this->_result, $offset)) { // Set the current row to the offset $this->_current_row = $this->_internal_row = $offset; return TRUE; } else { return FALSE; } }
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; } }
/** * Fetches the next result * @return array */ function fetch() { if ($row = sqlite_fetch_array($this->query)) { return $row; } else { if ($this->size() > 0) { sqlite_seek($this->query, 0); return false; } else { return false; } } }
/** * Constructor method for the adapter. This constructor implements the setting of the * 3 required properties for the object. * * @param resource $d The datasource resource */ function sqliteAdapter($d) { parent::RecordSetAdapter($d); // grab all of the rows $fieldcount = sqlite_num_fields($d); $ob = ""; $fc = pack('N', $fieldcount); if (sqlite_num_rows($d) > 0) { sqlite_seek($d, 0); while ($line = sqlite_fetch_array($d, SQLITE_NUM)) { //Write array flag + length $ob .= "\n" . $fc; $to = count($line); for ($i = 0; $i < $to; $i++) { //Type everything as a string since this is sqlite $value = $line[$i]; $os = $this->_directCharsetHandler->transliterate($value); //string flag, string length, and string $len = strlen($os); if ($len < 65536) { $ob .= "" . pack('n', $len) . $os; } else { $ob .= "\f" . pack('N', $len) . $os; } } } } // grab the number of fields // loop over all of the fields for ($i = 0; $i < $fieldcount; $i++) { // decode each field name ready for encoding when it goes through serialization // and save each field name into the array $this->columnNames[$i] = $this->_directCharsetHandler->transliterate(sqlite_field_name($d, $i)); } $this->numRows = sqlite_num_rows($d); $this->serializedData = $ob; }
function fetchSpecificRow($num, $type = "", $stack = 0) { if ($type == "") { $type = SQLITE_BOTH; } else { if ($type == "num") { $type = SQLITE_NUM; } else { if ($type == "assoc") { $type = SQLITE_ASSOC; } } } if (!$this->result[$stack]) { log_message("DB: called fetchSpecificRow[{$stack}] but result is false"); return; } sqlite_seek($this->result[$stack], $num); return @sqlite_fetch_array($this->result[$stack], $type); }
/** * Fetch a row and insert the data into an existing array. * * Formating of the array and the data therein are configurable. * See DB_result::fetchInto() for more information. * * @param resource $result query result identifier * @param array $arr (reference) array where data from the row * should be placed * @param int $fetchmode how the resulting array should be indexed * @param int $rownum the row number to fetch * * @return mixed DB_OK on success, null when end of result set is * reached or on failure * * @see DB_result::fetchInto() * @access private */ function fetchInto($result, &$arr, $fetchmode, $rownum = null) { if ($rownum !== null) { if (!@sqlite_seek($this->result, $rownum)) { return null; } } if ($fetchmode & DB_FETCHMODE_ASSOC) { $arr = @sqlite_fetch_array($result, SQLITE_ASSOC); if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) { $arr = array_change_key_case($arr, CASE_LOWER); } } else { $arr = @sqlite_fetch_array($result, SQLITE_NUM); } if (!$arr) { /* See: http://bugs.php.net/bug.php?id=22328 */ return null; } if ($this->options['portability'] & DB_PORTABILITY_RTRIM) { /* * Even though this DBMS already trims output, we do this because * a field might have intentional whitespace at the end that * gets removed by DB_PORTABILITY_RTRIM under another driver. */ $this->_rtrimArrayValues($arr); } if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) { $this->_convertNullArrayValuesToEmpty($arr); } return DB_OK; }
/** * Moves internal result pointer. * @param resource $resultSet * @param int $offset * @return bool * @throws DriverException */ public function seek($resultSet, $offset) { if ($this->unbuffered) { throw new DriverException('Cannot seek on unbuffered result.'); } return @sqlite_seek($resultSet, $offset); }
/** * Move internal result pointer * * Moves the pointer within the query result to a specified location, or * to the beginning if nothing is specified. * * @param resource $result Resultset * @param integer $rowNumber Row number * * @return boolean */ public function resultSeek($result, $rowNumber) { return sqlite_seek($result, $rowNumber); }
function sql_result($result, $row, $field = 0) { $check = sqlite_seek($result, $row); if ($check === false) { output_error("SQL Error: " . sql_error(), E_USER_ERROR); return false; } $trow = sqlite_fetch_array($result); $retval = $trow[$field]; return $retval; }
function seek($offset) { return sqlite_seek($this->id, $offset); }
/** * Return the wanted row from a given result set as * associative array */ function res2row($res, $rownum = 0) { if ($this->extension == DOKU_EXT_SQLITE) { if (!@sqlite_seek($res, $rownum)) { return false; } return sqlite_fetch_array($res, SQLITE_ASSOC); } else { if (!$res) { return false; } return $res->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, $rownum); } }
/** * Moves cursor position without fetching row. * @param int the 0-based cursor pos to seek to * @return boolean TRUE on success, FALSE if unable to seek to specified record * @throws DibiException */ public function seek($row) { if (!$this->buffered) { throw new DibiNotSupportedException('Cannot seek an unbuffered result set.'); } return sqlite_seek($this->resultSet, $row); }
/** * Data Seek * * Moves the internal pointer to the desired offset. We call * this internally before fetching results to make sure the * result set starts at zero * * @access private * @return array */ function _data_seek($n = 0) { return sqlite_seek($this->result_id, $n); }
function _seek($row) { return sqlite_seek($this->_queryID, $row); }
/** * Seek to a specific row in a result set * * @param int $rownum number of the row where the data can be found * @return mixed MDB2_OK on success, a MDB2 error on failure * @access public */ function seek($rownum = 0) { if (!@sqlite_seek($this->result, $rownum)) { if ($this->result === false) { return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'resultset has already been freed', __FUNCTION__); } elseif (is_null($this->result)) { return MDB2_OK; } return $this->db->raiseError(MDB2_ERROR_INVALID, null, null, 'tried to seek to an invalid row number (' . $rownum . ')', __FUNCTION__); } $this->rownum = $rownum - 1; return MDB2_OK; }
foreach ($queries as $query) { sqlite_exec($fs, $query); } // // Injection des données en provenance de la base MySQL // $db = WaDatabase($dsn); $tableList = array('wa_abo_liste', 'wa_abonnes', 'wa_admin', 'wa_auth_admin', 'wa_ban_list', 'wa_config', 'wa_forbidden_ext', 'wa_joined_files', 'wa_liste', 'wa_log', 'wa_log_files'); $tableList = str_replace('wa_', $prefixe, $tableList); foreach ($tableList as $table) { printf("Populate table %s...\n", $table); flush(); $fields = array(); $result = sqlite_query($fs, "PRAGMA table_info({$table})"); for ($i = 0, $m = sqlite_num_rows($result); $i < $m; $i++) { sqlite_seek($result, $i); array_push($fields, sqlite_column($result, 'name')); } $fields = implode(', ', $fields); $result = $db->query("SELECT {$fields} FROM {$table}"); $result->setFetchMode(SQL_FETCH_NUM); $numrows = 0; while ($row = $result->fetch()) { $values = array(); $numrows++; foreach ($row as $value) { if (is_null($value)) { $value = 'NULL'; } else { $value = "'" . sqlite_escape_string($value) . "'"; }
function sqlitem_seek($result, $numrow) { die('sqlitem_seek not implemented in PDO'); return sqlite_seek($result, $numrow); }
/** * Internal method to seek to a specific row in a result resource * * @param Integer $offset The offset to seek to * @return Array Returns the field values */ public function seek($offset) { sqlite_seek($this->result, $offset); }
function RewindDataSet(&$DataSet, $Position = '0') { $Position = ForceInt($Position, 0); sqlite_seek($DataSet, $Position); }
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; } }
/** * 获得所有的查询数据 * @access private * @return array */ private function getAll() { //返回数据集 $result = array(); if($this->numRows >0) { for($i=0;$i<$this->numRows ;$i++ ){ // 返回数组集 $result[$i] = sqlite_fetch_array($this->queryID,SQLITE_ASSOC); } sqlite_seek($this->queryID,0); } return $result; }
/** * Place le pointeur de résultat sur la position indiquée * * @param Ressource $r Ressource de résultat * @param int $row_number Position. Déplacer le pointeur à cette ligne * @param string $serveur Nom de la connexion * @param bool $requeter Inutilisé * @return bool True si déplacement réussi, false sinon. **/ function spip_sqlite_seek($r, $row_number, $serveur = '', $requeter = true) { if ($r) { $link = _sqlite_link($serveur); if (_sqlite_is_version(3, $link)) { // encore un truc de bien fichu : PDO ne PEUT PAS faire de seek ou de rewind... // je me demande si pour sqlite 3 il ne faudrait pas mieux utiliser // les nouvelles fonctions sqlite3_xx (mais encore moins presentes...) return false; } else { return sqlite_seek($r, $row_number); } } }
/** * seek to a specific row in a result set * * @param int $rownum number of the row where the data can be found * @return mixed MDB2_OK on success, a MDB2 error on failure * @access public */ function seek($rownum = 0) { if (!@sqlite_seek($this->result, $rownum)) { if (is_null($this->result)) { return $this->mdb->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'seek: resultset has already been freed'); } return $this->mdb->raiseError(MDB2_ERROR_INVALID, null, null, 'seek: tried to seek to an invalid row number (' . $rownum . ')'); } $this->rownum = $rownum - 1; return MDB2_OK; }
print " html_end_links();\n"; print "\n"; print " print(\"<h1>New {$tname}</h1>\\n\");\n"; print " print(\"<form method='post' action='\$PHP_SELF?N'>\"\n"; print "\t .\"<p><table width='100%' cellpadding='5' cellspacing='0' border='0'>\\n\");\n"; print "\n"; print " if (\$LOGIN_USER != \"\")\n"; print " {\n"; print " print(\"<tr><th align='right'>Published:</th><td>\");\n"; print " select_is_published();\n"; print " print(\"</td></tr>\\n\");\n"; print " }\n"; print " else\n"; print " print(\"<input type='hidden' name='IS_PUBLISHED' value='0'/>\\n\");\n"; print "\n"; sqlite_seek($result, 0); while ($row = sqlite_fetch_array($result)) { switch ($row['name']) { case "id": case "create_date": case "create_user": case "modify_date": case "modify_user": case "is_published": break; default: $form = strtoupper($row['name']); $name = ucwords(str_replace('_', ' ', $row['name'])); print " print(\"<tr><th align='right'>{$name}:</th>\"\n"; if ($row['type'] == "TEXT") { print "\t .\"<td><textarea name='{$form}' \"\n";
/** * Places a row from the result set into the given array * * Formating of the array and the data therein are configurable. * See DB_result::fetchInto() for more information. * * This method is not meant to be called directly. Use * DB_result::fetchInto() instead. It can't be declared "protected" * because DB_result is a separate object. * * @param resource $result the query result resource * @param array $arr the referenced array to put the data in * @param int $fetchmode how the resulting array should be indexed * @param int $rownum the row number to fetch (0 = first row) * * @return mixed DB_OK on success, NULL when the end of a result set is * reached or on failure * * @see DB_result::fetchInto() */ function fetchInto($result, &$arr, $fetchmode, $rownum = null) { if ($rownum !== null) { if (!@sqlite_seek($this->result, $rownum)) { return null; } } if ($fetchmode & DB_FETCHMODE_ASSOC) { $arr = @sqlite_fetch_array($result, SQLITE_ASSOC); if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) { $arr = array_change_key_case($arr, CASE_LOWER); } /* Remove extraneous " characters from the fields in the result. * Fixes bug #11716. */ if (is_array($arr) && count($arr) > 0) { $strippedArr = array(); foreach ($arr as $field => $value) { $strippedArr[trim($field, '"')] = $value; } $arr = $strippedArr; } } else { $arr = @sqlite_fetch_array($result, SQLITE_NUM); } if (!$arr) { return null; } if ($this->options['portability'] & DB_PORTABILITY_RTRIM) { /* * Even though this DBMS already trims output, we do this because * a field might have intentional whitespace at the end that * gets removed by DB_PORTABILITY_RTRIM under another driver. */ $this->_rtrimArrayValues($arr); } if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) { $this->_convertNullArrayValuesToEmpty($arr); } return DB_OK; }