当前位置: 首页>>代码示例>>PHP>>正文


PHP sqlite_last_insert_rowid函数代码示例

本文整理汇总了PHP中sqlite_last_insert_rowid函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlite_last_insert_rowid函数的具体用法?PHP sqlite_last_insert_rowid怎么用?PHP sqlite_last_insert_rowid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sqlite_last_insert_rowid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insertPostIndex

 public function insertPostIndex($historyid, $deleted)
 {
     $query = "INSERT INTO  postIndex (historyid, deleted) values (\"" . $historyid . "\", \"" . $deleted . "\")";
     $result = sqlite_query($this->db, $query);
     $postid = sqlite_last_insert_rowid($this->db);
     return $postid;
 }
开发者ID:sleepyycat,项目名称:WebFramework,代码行数:7,代码来源:PostDB.class.php

示例2: insertSumData

 public function insertSumData($time, $type, $pvNum, $bidNum, $imprNum, $prodName, $version, $ts)
 {
     $query = "INSERT INTO  sumData (time, type, pvNum, bidNum, imprNum, prodName, version, ts) values (\"" . $time . "\", \"" . $type . "\", \"" . $pvNum . "\", \"" . $bidNum . "\",\"" . $imprNum . "\",\"" . $prodName . "\",\"" . $version . "\",\"" . $ts . "\")";
     $result = sqlite_query($this->db, $query);
     $id = sqlite_last_insert_rowid($this->db);
     return $id;
 }
开发者ID:sleepyycat,项目名称:WebFramework,代码行数:7,代码来源:MonitorDB.class.php

示例3: sendQuery

 /**
  * Method to send SQL query
  *
  * @param   resource    $res_conn
  * @return  void
  */
 private function sendQuery($res_conn)
 {
     // checking query type
     // if the query return recordset or not
     if (preg_match("/^(SELECT)\\s/i", $this->sql_string)) {
         $this->res_result = @sqlite_query($res_conn, $this->sql_string);
         // error checking
         if (!$this->res_result) {
             $this->errno = sqlite_last_error($res_conn);
             $this->error = "Query failed to executed. Please check your query again. \n" . sqlite_error_string($this->errno);
         } else {
             // count number of rows
             $this->num_rows = @sqlite_num_rows($this->res_result);
         }
     } else {
         $_query = @sqlite_unbuffered_query($res_conn, $this->sql_string);
         $this->insert_id = sqlite_last_insert_rowid($res_conn);
         // error checking
         if (!$_query) {
             $this->errno = sqlite_last_error($res_conn);
             $this->error = "Query failed to executed. Please check your query again. \n" . sqlite_error_string($this->errno);
         } else {
             // get number of affected row
             $this->affected_rows = @sqlite_changes($res_conn);
         }
         // nullify query
         $_query = null;
     }
 }
开发者ID:purwoko,项目名称:SENAYAN-3-Stable,代码行数:35,代码来源:simbio_sqlite_result.inc.php

示例4: save

 function save($table, $data)
 {
     // SAVES data to table
     //Creates table if doesn't exist
     // data is serialized to 1 string.  will be unserialized later.
     // if first tuple exists new data is merged.
     // DATA will be REPLACED on identical KEYs
     $cnt = 0;
     if (!$data) {
         return;
     }
     $this->findkey($table, $data);
     if ($this->match == 0) {
         return;
     }
     // for no matches when 'idx'=XX
     if ($this->match == -1) {
         $dat = serialize($data);
         //*
         // this routine is due to sqlite 2 , 'IF NOT EXIST' only available in sqlite3
         do {
             if ($cnt++ > 10) {
                 break;
             }
             // Only loop to 10 incase something goes wrong
             sqlite_exec($this->handle, "INSERT INTO {$table} (data1) VALUES ('{$dat}')", $sqliteerr);
             if ($sqliteerr) {
                 if ($sqliteerr == "no such table: {$table}") {
                     $strCreate = "CREATE TABLE {$table} (idx integer primary key, data1 text)";
                     sqlite_exec($this->handle, $strCreate, $err1);
                     if ($err1) {
                         echo "Error Creating Table:<br><b>" . $err1 . "</b><br>";
                     }
                 }
             }
             $idd = sqlite_last_insert_rowid($this->handle);
         } while ($sqliteerr);
         //*/
     } else {
         $arr = $this->match;
         $d1 = array_shift($data);
         // First element is find only;
         foreach ($arr as $id) {
             $copy = $this->getbyid($table, $id);
             //echo "COPY $id <pre style='background-color:#c0ffee'>";print_r($copy);echo "</pre>";
             //echo "DATA $id <pre style='background-color:#c0ffee'>";print_r($data);echo "</pre>";
             $newarr = array_merge($copy, $data);
             $dat = serialize($newarr);
             $str = "UPDATE {$table} SET data1= '{$dat}' WHERE idx=" . $id;
             sqlite_exec($this->handle, $str, $err1);
             if ($err1) {
                 echo "ERR1:" . $err1 . "<br>";
             }
         }
     }
     //$this->getall($table);
     $idd = sqlite_last_insert_rowid($this->handle);
     return $idd;
 }
开发者ID:patmoldovan,项目名称:SQLite-Data-Layer,代码行数:59,代码来源:sqlitelayer.php

示例5: insert_id

 function insert_id()
 {
     $result = @sqlite_last_insert_rowid($this->connection);
     if (!$result) {
         return $this->sqliteRaiseError();
     } else {
         return $result;
     }
 }
开发者ID:powerpbx,项目名称:framework,代码行数:9,代码来源:freepbx_DB_extends.php

示例6: sql_insert_id

function sql_insert_id()
{
    global $con;
    if (defined('DB_TYPE')) {
        if (DB_TYPE == 'mysql') {
            $sql = mysql_insert_id();
        } elseif (DB_TYPE == 'sqlite') {
            $sql = sqlite_last_insert_rowid($con);
        }
    }
    return $sql;
}
开发者ID:eodivision,项目名称:eoCMS,代码行数:12,代码来源:sql_insert_id.php

示例7: dbLastId

	function dbLastId($db) {
		global $DBProvider;
		switch($DBProvider){
			case 'sqlite':
				return sqlite_last_insert_rowid($db);
				break;
			case 'mysql':
			default:
				return mysql_insert_id($db);
			break;
		}	
	}
开发者ID:Tetting,项目名称:Shorty,代码行数:12,代码来源:local_DBNamespace.php

示例8: _timeconditions_timegroups_add_group_timestrings

function _timeconditions_timegroups_add_group_timestrings($description, $timestrings)
{
    global $db;
    $sql = "insert timegroups_groups(description) VALUES ('{$description}')";
    $db->query($sql);
    if (method_exists($db, 'insert_id')) {
        $timegroup = $db->insert_id();
    } else {
        $timegroup = $amp_conf["AMPDBENGINE"] == "sqlite3" ? sqlite_last_insert_rowid($db->connection) : mysql_insert_id($db->connection);
    }
    _timeconditions_timegroups_edit_timestrings($timegroup, $timestrings);
    return $timegroup;
}
开发者ID:ringfreejohn,项目名称:pbxframework,代码行数:13,代码来源:install.php

示例9: __construct

 /**
  * Run a query
  *
  * @param string $sql
  * @param resource $connection DB Connection
  * @throws Exception MySQL error
  */
 public function __construct($sql, $connection)
 {
     parent::__construct($sql);
     $this->connection = $connection;
     $errorMessage = '';
     // Overwritten by sqlite_query
     $resource = sqlite_query($this->connection, $sql, SQLITE_ASSOC, $errorMessage);
     if (false === $resource) {
         throw new Exception('SQLite Error: ' . $errorMessage);
     } else {
         $this->resource = $resource;
         $this->setNumberOfRows(sqlite_num_rows($resource));
         $this->columns = $this->getColumnTypes();
         $this->rowsAffected = sqlite_changes($this->connection);
         $this->lastId = sqlite_last_insert_rowid($this->connection);
     }
 }
开发者ID:chrismcmacken,项目名称:phptools,代码行数:24,代码来源:Result.php

示例10: add

function add($db)
{
    // takes data from POST array
    $name = $_POST['name'];
    $age = $_POST['age'];
    $group_name = $_POST['group'];
    $city = $_POST['city'];
    $phone = $_POST['phone'];
    $sex = $_POST['sex'];
    $driver_license = $_POST['driver_license'];
    // add to database
    $query = "INSERT INTO 'users' VALUES(null, '{$name}','{$age}','{$group_name}','{$city}','{$phone}','{$sex}','{$driver_license}')";
    $result = sqlite_query($query, $db);
    if ($result) {
        return sqlite_last_insert_rowid($db);
    }
    return "false";
}
开发者ID:mudassartufail,项目名称:dhtmlx,代码行数:18,代码来源:data.php

示例11: LogonOK

	function LogonOK($user) {
		global $db;
		$_SESSION["UserName"] = $user['Username'];
 		$_SESSION["UserData"] = $user;
		$_SESSION["Db"] = $user['Db'];
		unset($_SESSION["UserData"]["Password"]);//do not store the password.
		print '{"LoginOk":"'.$user['Username'].'","UserId":"'.$user['Id'].'"}';	 //can output permissions objects etc as well.
		flush();
		$sql = "Update User Set LastLogin=datetime('now','localtime') where Id='${user['Id']}'";		
		$result = sqlite_query($db,$sql);
		sqlite_close($db);
		//$db = sqlite_open("../data/log.sdb");
		$db = dbConnect('log');
		$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
		$host = sqlite_escape_string(gethostbyaddr($ip));$ip=sqlite_escape_string($ip);
		$sql = "INSERT INTO Login(ID,UserName,Time,ip,hostname,Result)VALUES(Null,'".$user['Username']."',DATETIME('NOW'),'$ip','$host','LogonOK')";
		$result = sqlite_query($db,$sql);
		$_SESSION["SESSION_DBID"] = sqlite_last_insert_rowid($db);
	}
开发者ID:Tetting,项目名称:Shorty,代码行数:19,代码来源:login.php

示例12: Query

 public function Query($query)
 {
     if (!$this->IsConnected()) {
         throw new Exception("Not Connected to DB.");
     }
     #echo "$query\n";
     #$result = sqlite_unbuffered_query($query, $this->link);
     $result = sqlite_query($query, $this->link);
     if (!$result) {
         throw new Exception("Query Failed: '{$query}'");
     }
     $num = sqlite_num_rows($result);
     if ($num > 0) {
         for ($i = 0; $i < $num; $i++) {
             $rows[$i] = sqlite_fetch_array($result, SQLITE_ASSOC);
         }
         return $rows;
     } else {
         return sqlite_last_insert_rowid($this->link);
     }
 }
开发者ID:mmr,项目名称:b1n,代码行数:21,代码来源:SQLite.php

示例13: insert_id

 function insert_id()
 {
     return $this->link_id ? @sqlite_last_insert_rowid($this->link_id) : false;
 }
开发者ID:BlitzFirePlayz,项目名称:Luna,代码行数:4,代码来源:sqlite.php

示例14: query

 function query($query)
 {
     // For reg expressions
     $query = str_replace("/[\n\r]/", '', trim($query));
     // initialise return
     $return_val = 0;
     // Flush cached values..
     $this->flush();
     // Log how the function was called
     $this->func_call = "\$db->query(\"{$query}\")";
     // Keep track of the last query for debug..
     $this->last_query = $query;
     // Perform the query via std mysql_query function..
     $this->result = @sqlite_query($this->dbh, $query);
     $this->count(true, true);
     // If there is an error then take note of it..
     if (@sqlite_last_error($this->dbh)) {
         $err_str = sqlite_error_string(sqlite_last_error($this->dbh));
         $this->register_error($err_str);
         $this->show_errors ? trigger_error($err_str, E_USER_WARNING) : null;
         return false;
     }
     // Query was an insert, delete, update, replace
     if (preg_match("/^(insert|delete|update|replace)\\s+/i", $query)) {
         $this->rows_affected = @sqlite_changes($this->dbh);
         // Take note of the insert_id
         if (preg_match("/^(insert|replace)\\s+/i", $query)) {
             $this->insert_id = @sqlite_last_insert_rowid($this->dbh);
         }
         // Return number fo rows affected
         $return_val = $this->rows_affected;
     } else {
         // Take note of column info
         $i = 0;
         while ($i < @sqlite_num_fields($this->result)) {
             $this->col_info[$i]->name = sqlite_field_name($this->result, $i);
             $this->col_info[$i]->type = null;
             $this->col_info[$i]->max_length = null;
             $i++;
         }
         // Store Query Results
         $num_rows = 0;
         while ($row = @sqlite_fetch_array($this->result, SQLITE_ASSOC)) {
             // Store relults as an objects within main array
             $obj = (object) $row;
             //convert to object
             $this->last_result[$num_rows] = $obj;
             $num_rows++;
         }
         // Log number of rows the query returned
         $this->num_rows = $num_rows;
         // Return number of rows selected
         $return_val = $this->num_rows;
     }
     // If debug ALL queries
     $this->trace || $this->debug_all ? $this->debug() : null;
     return $return_val;
 }
开发者ID:xFanly,项目名称:ezSQL,代码行数:58,代码来源:ez_sql_sqlite.php

示例15: _insertid

 function _insertid()
 {
     return sqlite_last_insert_rowid($this->_connectionID);
 }
开发者ID:teddywen,项目名称:cacti,代码行数:4,代码来源:adodb-sqlite.inc.php


注:本文中的sqlite_last_insert_rowid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。