示例#1
0
 function loadTables()
 {
     if ($this->isExisting) {
         $sql = "SELECT name FROM sqlite_master WHERE type='table' UNION ALL " . "SELECT name FROM sqlite_temp_master WHERE type='table' ORDER BY name;";
         $queryId = $this->connection->execute($sql);
         while (sqlite_has_more($queryId)) {
             $this->tables[sqlite_fetch_single($queryId)] = null;
         }
         $this->isTablesLoaded = true;
     }
 }
/**
* raw_db_list_database_tables()
* Returns an array with the list of tables of the current database.
*
* @return array or FALSE
*/
function raw_db_list_database_tables()
{
    global $g_current_db;
    $tables = array();
    $sql = "SELECT name FROM sqlite_master WHERE (type = 'table')";
    $res = sqlite_query($g_current_db, $sql);
    if ($res) {
        while (sqlite_has_more($res)) {
            $tables[] = sqlite_fetch_single($res);
        }
    } else {
        return false;
    }
    return $tables;
}
function getLabel($url)
{
    $dbhandle = sqlite_open('labelcache.db');
    if (!sqlite_has_more(sqlite_query($dbhandle, "SELECT name FROM sqlite_master WHERE name='labels'"))) {
        sqlite_query($dbhandle, "CREATE TABLE labels (url,label)");
    }
    $query = sqlite_query($dbhandle, 'SELECT label FROM labels WHERE url="' . $url . '"');
    $result = sqlite_fetch_single($query, SQLITE_ASSOC);
    if (empty($result)) {
        $label = retrieveLabel($url);
        sqlite_query($dbhandle, "INSERT INTO labels (url,label) VALUES ('{$url}','" . sqlite_escape_string($label) . "');");
        return $label;
    } else {
        return $result;
    }
}
示例#4
0
<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>
示例#5
0
function create($db)
{
    $q = "SELECT name FROM sqlite_master WHERE type='table' AND name='Logs';";
    $result = sqlite_query($db, $q, SQLITE_NUM);
    if (!$result) {
        die("Cannot execute query. {$q}");
    }
    if (!sqlite_has_more($result)) {
        // no table found - create it
        $q = 'CREATE TABLE Logs(' . '  id INTEGER PRIMARY KEY,' . '  title TEXT,' . '  content TEXT NOT NULL,' . '  tags TEXT,' . '  t TIMESTAMP,' . '  state INT' . ');';
        $ok = sqlite_exec($db, $q, $error);
        if (!$ok) {
            die("Cannot execute query {$q}. {$error}");
        }
    }
}
示例#6
0
function sqlitem_has_more($result)
{
    die('sqlitem_has_more not implemented in PDO');
    return sqlite_has_more($result);
}
示例#7
0
function sqlitem_has_more($result)
{
    return sqlite_has_more($result);
}
示例#8
0
<?php

$dbhandle = sqlite_open('log');
if ($dbhandle == false) {
    die('Unable to open database');
} else {
    echo 'Database created.';
}
$dbquery = ' SELECT * FROM tbl1';
$dbresult = sqlite_query($dbhandle, $dbquery);
while (sqlite_has_more($dbresult)) {
    $dbrow = sqlite_fetch_single($dbquery);
    print_r($dbrow);
}
sqlite_close($dbhandle);
示例#9
0
 function GetValue($query)
 {
     $result = sqlite_query($query, $this->link);
     /* Increment the number of queries */
     $this->num_queries++;
     if (is_resource($result)) {
         if (sqlite_has_more($result)) {
             $value = sqlite_fetch_single($result);
             if (DEBUG_SQL) {
                 set_debug_item($query, $value);
             }
             return $value;
         }
     } else {
         return compile_error("Invalid query: " . sqlite_error_string(sqlite_last_error($this->link)), __FILE__, __LINE__);
     }
     return FALSE;
 }
示例#10
0
 public function GetValue($query)
 {
     $result = sqlite_unbuffered_query($this->link, $query);
     if (is_resource($result)) {
         if (sqlite_has_more($result)) {
             $value = sqlite_fetch_single($result);
             $this->num_queries = $this->num_queries + 1;
             return $value;
         }
     } else {
         throw new DBA_Exception(DBA::E_INVALID_QUERY, sqlite_error_string(sqlite_last_error($this->link)));
     }
     return FALSE;
 }
示例#11
0
文件: db.php 项目: thu0ng91/jmc
 /**
  * 列出一个数据库内所有表
  * 
  * @param      void
  * @access     public
  * @return     array
  */
 function list_tables()
 {
     if (function_exists('sqlite_list_tables')) {
         return sqlite_list_tables();
     } else {
         $tables = array();
         $sql = "SELECT name FROM sqlite_master WHERE (type = 'table')";
         if ($res = sqlite_query($this->conn, $sql)) {
             while (sqlite_has_more($res)) {
                 $tables[] = sqlite_fetch_single($res);
             }
         }
         return $tables;
     }
 }
示例#12
0
 while ($result = sqlite_fetch_array($rh)) {
     var_dump($result);
 }
 // simple fetch_object loop
 // php5 dumps objects differently
 /*    echo "fetching results object\n";
     sqlite_rewind($rh);
     while ($result = sqlite_fetch_object($rh)) {
         var_dump($result);
     }*/
 // rewind/next loop
 sqlite_rewind($rh);
 while (sqlite_next($rh)) {
     $result = sqlite_current($rh);
     var_dump($result);
     $b = sqlite_has_more($rh);
     echo "has_more?\n";
     $b = sqlite_valid($rh);
     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);