本文整理汇总了PHP中sqlite_exec函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlite_exec函数的具体用法?PHP sqlite_exec怎么用?PHP sqlite_exec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlite_exec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query
/**
* 执行mysql query()操作
* @param string $sql
* @return mixed
*/
public function query($sql)
{
// 是否记录 SQL log
if (true == C('sql_log')) {
wlog('SQL-Log', $sql);
}
$error_msg = '';
$_key = strtolower(substr($sql, 0, 6));
if ($_key == 'select') {
$rs = sqlite_query($this->db, $sql, SQLITE_BOTH, $error_msg);
} else {
$rs = sqlite_exec($this->db, $sql, $error_msg);
}
if (!empty($rs)) {
$GLOBALS['run_dbquery_count']++;
return $rs;
} else {
if (C('show_errors')) {
show_error('执行sqlite_query()出现错误: ' . $error_msg . '<br />原SQL: ' . $sql);
} else {
exit('db_sqlite2::query() error.');
}
}
//return false;
}
示例2: exec
/**
* 結果を返さないクエリを実行する。
*
* @param string $query SQL文。
* @return void
*/
function exec($query)
{
$result = sqlite_exec($this->link, $query);
if ($result == false) {
throw new DBException('クエリを実行できませんでした。', $query, $this->link);
}
}
示例3: exec
function exec($query)
{
$this->error = "";
if ($this->versi == 3) {
return $this->db->exec($query);
} else {
return sqlite_exec($this->db, $query, $this->error);
}
}
示例4: __construct
/**
* Constructor
*/
public function __construct()
{
//Abre una conexión SqLite a la base de datos cache
$this->_db = sqlite_open(':memory:');
$result = sqlite_query($this->_db, "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND tbl_name='cache' ");
$count = sqlite_fetch_single($result);
if (!$count) {
sqlite_exec($this->_db, ' CREATE TABLE cache (id TEXT, "group" TEXT, value TEXT, lifetime TEXT) ');
}
return $this->_db;
}
示例5: hasListing
public function hasListing($a_sListingURL)
{
$l_sTmp = md5($a_sListingURL);
$result = sqlite_query($this->db, "SELECT * FROM listings WHERE l_id = '" . $l_sTmp . "'");
$rows = sqlite_num_rows($result);
if ($rows < 1) {
$result = sqlite_exec($this->db, "INSERT INTO listings VALUES ('{$l_sTmp}')");
return false;
} else {
return true;
}
}
示例6: execute
public function execute($sql, $params = array())
{
foreach ($params as $k => $v) {
$sql = str_replace(':' . $k, $this->escape($v), $sql);
}
$this->sql = $sql;
if ($query = sqlite_exec($this->_getWriteLink(), $sql, $error_msg)) {
return $query;
} else {
$this->error($error_msg);
}
}
示例7: exec
public function exec($sql, $connResource)
{
if (empty($sql)) {
return 0;
}
sqlite_exec($connResource, $sql);
// echo '<pre>';
// print_r(debug_backtrace());
// debug_print_backtrace();
// echo '</pre>';
// delete from table 结果为0,原因未知。
// 使用 delete from table where 1 能返回正确结果
return sqlite_changes($connResource);
}
示例8: add
public function add($ip, $comment)
{
$comment = self::trunc($comment);
$ip = "'" . sqlite_escape_string($ip) . "'";
if ($comment == '') {
sqlite_exec($this->handle, "delete from comments where ip=" . $ip, $this->error);
} else {
$comment = "'" . sqlite_escape_string($comment) . "'";
if (($query = sqlite_unbuffered_query($this->handle, "select count(comment) from comments where ip=" . $ip, SQLITE_ASSOC, $this->error)) && sqlite_fetch_single($query)) {
sqlite_exec($this->handle, "update comments set comment=" . $comment . " where ip=" . $ip, $this->error);
} else {
sqlite_exec($this->handle, "insert into comments (ip,comment) values (" . $ip . "," . $comment . ")", $this->error);
}
}
}
示例9: exec
public function exec($sql)
{
if (strtolower(substr($sql, 0, 6)) == 'select') {
$res = sqlite_query($this->dbcon, $sql, SQLITE_BOTH, $error_msg);
if ($error_msg) {
echo 'Query Error: ' . $error_msg;
}
} else {
$res = sqlite_exec($this->dbcon, $sql, $error_msg);
if ($error_msg) {
echo 'Query Error: ' . $error_msg;
}
}
return $res;
}
示例10: formthrottle_too_many_submissions
function formthrottle_too_many_submissions($ip)
{
$tooManySubmissions = false;
if (function_exists("sqlite_open") and $db = @sqlite_open('muse-throttle-db', 0666, $sqliteerror)) {
$ip = @sqlite_escape_string($ip);
@sqlite_exec($db, "DELETE FROM Submission_History WHERE Submission_Date < DATETIME('now','-2 hours')", $sqliteerror);
@sqlite_exec($db, "INSERT INTO Submission_History (IP,Submission_Date) VALUES ('{$ip}', DATETIME('now'))", $sqliteerror);
$res = @sqlite_query($db, "SELECT COUNT(1) FROM Submission_History WHERE IP = '{$ip}';", $sqliteerror);
if (@sqlite_num_rows($res) > 0 and @sqlite_fetch_single($res) > 25) {
$tooManySubmissions = true;
}
@sqlite_close($db);
}
return $tooManySubmissions;
}
示例11: connect
function connect()
{
if (!file_exists(FILE)) {
$initReq = true;
}
$GLOBALS['sqlConnect'] = sqlite_open(FILE, 0666);
if (!$GLOBALS['sqlConnect']) {
return false;
}
if ($initReq) {
$initSQL = "CREATE TABLE wwwsqldesigner (\r\n keyword varchar(30) NOT NULL default '',\r\n data TEXT ,\r\n dt DATETIME DEFAULT CURRENT_TIMESTAMP ,\r\n PRIMARY KEY ( keyword )\r\n );";
$res = sqlite_exec($initSQL, $GLOBALS['sqlConnect']);
return $res;
}
return true;
}
示例12: setup
public function setup($cacheinfo)
{
//check if the db has been setup
$this->cachebase = "app/cache/";
if (!empty($cacheinfo)) {
$this->cachefile = $cacheinfo['dbname'];
}
$this->cachefile = $this->cachebase . $this->cachefile;
if (!file_exists($this->cachefile)) {
$this->cachedb = sqlite_open($this->cachefile, 0666);
sqlite_exec("create table cache ( marker VARCHAR PRIMARY KEY, content TEXT, modified INT, valid INT, expired INTEGER DEFAULT 0) ", $this->cachedb);
//sqlite_exec("create index marker on cache (marker) ",$this->cachedb);
} else {
$this->cachedb = sqlite_open($this->cachefile, 0666);
}
}
示例13: open
public static function open()
{
// connect
$error_msg = null;
define('SESSION_DB_LINK', sqlite_open(DIR_DATA . '/sessions.db', 0666, $error_msg));
if (!SESSION_DB_LINK) {
warning("Can't open session database: {$error_msg}");
return false;
}
// check if required table exists, create it if necessary
$R = sqlite_query("SELECT name FROM sqlite_master WHERE type='table' AND name='sess'", SESSION_DB_LINK);
if (!sqlite_num_rows($R)) {
sqlite_exec("CREATE TABLE sess (id TEXT, data TEXT, expire INT)", SESSION_DB_LINK);
}
return true;
}
示例14: login
public function login($user, $password, $stayloggedin = false)
{
$user = sqlite_escape_string($user);
$password = md5($salt . $password);
$q = "SELECT * FROM users WHERE username = '{$user}' AND password = '{$password}' LIMIT 1";
$res = sqlite_query($this->db, $q, $e);
if (sqlite_num_rows($res) > 0) {
if ($stayloggedin) {
$r = sqlite_fetch_array($res);
setcookie("userid", $r['uid'], time() + 60 * 60 * 24 * 30);
setcookie("pass", $password, time() + 60 * 60 * 24 * 30);
}
$_SESSION['uid'] = $r['uid'];
$_SESSION['uname'] = $r['username'];
$time = time();
$id = $r['uid'];
sqlite_exec($this->db, "UPDATE users SET lastlogin = '{$time}' WHERE uid = '{$id}'", $e);
return true;
}
return false;
}
示例15: exec
public function exec($query)
{
# This method executes a query.
# @param string $query
# @return boolean
global $sqlite, $syslog;
ob_start();
// Start catching error messages
if (sqlite_exec($sqlite->handle, $query)) {
ob_end_clean();
$syslog->success('SQLObject', 'exec()', $query);
return true;
} else {
$this->error = strip_tags(ob_get_contents(), '<strong><b>');
// Get the error message from the buffer
$this->sqlite_error = sqlite_error_string(sqlite_last_error($sqlite->handle));
// Get the error message of the error code
ob_end_clean();
$syslog->error('SQLObject', 'exec()', $query, $this->sqlite_error);
return false;
}
}