Example #1
0
 /**
  * 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;
 }
Example #2
0
     if (file_exists($queuefile) && filesize($queuefile) < 3000) {
         unlink($queuefile);
     }
     clearstatcache();
     if (!file_exists($queuefile)) {
         $db = sqlite_open($queuefile);
         sqlite_query($db, "BEGIN;\n\t\t\tCREATE TABLE notes( \n\t\t\t\tid INTEGER PRIMARY KEY, \n\t\t\t\tpage CHAR(100), \n\t\t\t\tlang CHAR(5),\n\t\t\t\tdate INT(11), \n\t\t\t\temail CHAR(700), \n\t\t\t\tdisplay CHAR(700),\n\t\t\t\tcomment CHAR(4000)); \n\t\t\tCOMMIT;");
         sqlite_close($db);
     }
     /* check for/create the last_id file while we're at it */
     if (!file_exists($last_id) || !file_get_contents($last_id) || file_get_contents($last_id == '0')) {
         $db = sqlite_open($notesfile);
         $estimate = sqlite_single_query($db, "SELECT COUNT(*) FROM notes");
         $setid = sqlite_query($db, "SELECT id FROM notes WHERE id > '{$estimate}'", SQLITE_ASSOC);
         if ($setid && sqlite_num_rows($setid) > 0) {
             while (sqlite_valid($setid)) {
                 $rowid = sqlite_fetch_single($setid);
             }
         } else {
             $rowid = $estimate;
         }
         file_put_contents($last_id, $rowid);
         sqlite_close($db);
     }
 }
 /* ============================ PREVIEW ONLY ========================= */
 if (isset($_POST['preview'])) {
     print "<br />\n<p>\nThis is what your entry will look like, roughly:\n</p>\n";
     print "<table border='0' cellpadding='0' cellspacing='0' width='100%' align = 'center'>\n";
     $temp = array('display' => $display, 'comment' => htmlentities($content), 'date' => time());
     makeEntry($temp, false);
Example #3
0
 public function valid()
 {
     return sqlite_valid($this->result);
 }
Example #4
0
    var_dump($errmsg);
}
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'));
Example #5
0
 }
 // 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);
 // prev loop
 while (sqlite_prev($rh)) {