コード例 #1
0
ファイル: sqlite3.php プロジェクト: GavinHellyer/Annexe-Media
 /**
  * Returns the next free id in a sequence
  *
  * @param string  $seq_name  name of the sequence
  * @param boolean $ondemand  when true, the seqence is automatically
  *                            created if it does not exist
  *
  * @return int  the next id number in the sequence.
  *               A DB_Error object on failure.
  *
  * @see DB_common::createSequence(), DB_common::dropSequence(),
  *      DB_common::getSequenceName()
  */
 function nextId($seq_name, $ondemand = true)
 {
     $sqn = $this->getSequenceName($seq_name);
     if ($ondemand) {
         $tables = $this->getTables();
         if (DB::isError($tables)) {
             return $tables;
         }
         if (!in_array($sqn, $tables)) {
             $res = $this->createSequence($seq_name);
             if (DB::isError($res)) {
                 return $res;
             }
         }
     }
     $res = $this->query("INSERT INTO " . $sqn . " VALUES (NULL)");
     if (DB::isError($res)) {
         return $res;
     }
     return sqlite3_last_insert_rowid($this->connection);
 }
コード例 #2
0
ファイル: sqlite3.inc.php プロジェクト: rustyx/Serendipity
/**
 * Returns the latest INSERT_ID of an SQL INSERT INTO command, for auto-increment columns
 *
 * @access public
 * @return int      Value of the auto-increment column
 */
function serendipity_db_insert_id()
{
    global $serendipity;
    return sqlite3_last_insert_rowid($serendipity['dbConn']);
}
コード例 #3
0
 function last_insert_id()
 {
     return $this->db ? sqlite3_last_insert_rowid($this->db) : FALSE;
 }
コード例 #4
0
ファイル: example2.php プロジェクト: jlduran/BAPS2
<?php

/*
 * you may need this line, depending on how you compile
 * this extension.
 */
dl('sqlite3.so');
/*
 * create a SQLite3 handle. 
 *
 * Note: in-memory database are created by the magic keyword ":memory:"
 *
 */
$db = sqlite3_open(":memory:");
if (!$db) {
    die("Could not create in-memory database..");
}
/*
 * create a simple test and insert some values..
 */
$ret = sqlite3_exec($db, "CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER);");
if (!$ret) {
    die(sqlite3_error($db));
}
sqlite3_exec($db, "INSERT INTO test (name,age) VALUES ('michael',32)");
echo "last rowid inserted : " . sqlite3_last_insert_rowid($db) . "\n";
sqlite3_exec($db, "INSERT INTO test (name,age) VALUES ('bob',27)");
echo "last rowid inserted : " . sqlite3_last_insert_rowid($db) . "\n";
sqlite3_exec($db, "INSERT INTO test (name,age) VALUES ('martin',12)");
echo "last rowid inserted : " . sqlite3_last_insert_rowid($db) . "\n";
sqlite3_close($db);
コード例 #5
0
ファイル: sqlite3_lt_php53.php プロジェクト: ReedME/heatCMS
 public function lastInsertRowID()
 {
     return sqlite3_last_insert_rowid($this->conn);
 }