/**
  * 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;
 }
Esempio n. 2
0
 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();
 }
Esempio n. 3
0
 function reset()
 {
     if ($this->row > 0) {
         sqlite_seek($this->id, 0);
     }
     $this->row = -1;
     return TRUE;
 }
Esempio n. 4
0
 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;
 }
Esempio n. 6
0
 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;
     }
 }
Esempio n. 7
0
 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;
     }
 }
Esempio n. 8
0
 /**
  * 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;
         }
     }
 }
Esempio n. 9
0
 /**
  * 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;
 }
Esempio n. 10
0
 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);
 }
Esempio n. 11
0
 /**
  * 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;
 }
Esempio n. 12
0
 /**
  * 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);
 }
Esempio n. 13
0
 /**
  * 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);
 }
Esempio n. 14
0
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;
}
Esempio n. 15
0
 function seek($offset)
 {
     return sqlite_seek($this->id, $offset);
 }
Esempio n. 16
0
 /**
  * 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);
 }
Esempio n. 18
0
 /**
  * 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);
 }
Esempio n. 19
0
 function _seek($row)
 {
     return sqlite_seek($this->_queryID, $row);
 }
Esempio n. 20
0
 /**
  * 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;
 }
Esempio n. 21
0
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) . "'";
            }
Esempio n. 22
0
function sqlitem_seek($result, $numrow)
{
    die('sqlitem_seek not implemented in PDO');
    return sqlite_seek($result, $numrow);
}
Esempio n. 23
0
 /**
  * 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);
 }
Esempio n. 25
0
 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;
     }
 }
Esempio n. 26
0
 /**
  * 获得所有的查询数据
  * @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;
 }
Esempio n. 27
0
/**
 * 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);
        }
    }
}
Esempio n. 28
0
 /**
  * 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;
 }
Esempio n. 29
0
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";
Esempio n. 30
0
 /**
  * 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;
 }