本文整理汇总了PHP中sqlite_fetch_single函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlite_fetch_single函数的具体用法?PHP sqlite_fetch_single怎么用?PHP sqlite_fetch_single使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlite_fetch_single函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOneColumnAsArray
function getOneColumnAsArray()
{
$column = array();
$queryId = $this->connection->execute($this->getSQL());
while ($value = sqlite_fetch_single($queryId)) {
$column[] = $value;
}
return $column;
}
示例2: __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;
}
示例3: loadTables
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;
}
}
示例4: getRedirectRoute
/**
* Get redirect route
*
* @param string $onMatchCondition (rejectCall | acceptCall)
* @return string returns the SIP URL
* @author John Dyer
*/
function getRedirectRoute($onMatchCondition){
global $dbPath;
$dbhandle = sqlite_open($dbPath,0666);
if ($onMatchCondition == "rejectCall"){
$sql = sqlite_query($dbhandle,"select value from data where id='rejectRedirectURL'");
$url = sqlite_fetch_single($sql);
}elseif ($onMatchCondition == "acceptCall"){
$sql = sqlite_query($dbhandle,"select value from data where id='acceptRedirectURL'");
$url = sqlite_fetch_single($sql);
}
// print ('<redirectRoute>' . urldecode($url) . '</redirectRoute>');
return urldecode($url);
}
示例5: insertid
function insertid()
{
if ($this->handler) {
$response = sqlite_query($this->handler, 'SELECT last_insert_rowid()');
if ($response) {
return sqlite_fetch_single($response);
} else {
return false;
}
} else {
die('データベースハンドラが見つかりません。');
}
}
示例6: raw_db_list_database_tables
/**
* 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;
}
示例7: get
public function get($name)
{
$this->Q(1);
$name = sqlite_escape_string($name);
$sql = 'SELECT ' . $this->options['value'] . ' FROM ' . $this->options['table'] . ' WHERE ' . $this->options['var'] . '=\'' . $name . '\' AND (' . $this->options['expire'] . '=-1 OR ' . $this->options['expire'] . '>' . time() . ') LIMIT 1';
$result = sqlite_query($this->handler, $sql);
if (sqlite_num_rows($result)) {
$content = sqlite_fetch_single($result);
if (C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
$content = gzuncompress($content);
}
return unserialize($content);
}
return false;
}
示例8: get
/**
* 读取缓存
* @access public
* @param string $name 缓存变量名
* @param mixed $default 默认值
* @return mixed
*/
public function get($name, $default = false)
{
$name = $this->getCacheKey($name);
$sql = 'SELECT value FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\' AND (expire=0 OR expire >' . $_SERVER['REQUEST_TIME'] . ') LIMIT 1';
$result = sqlite_query($this->handler, $sql);
if (sqlite_num_rows($result)) {
$content = sqlite_fetch_single($result);
if (function_exists('gzcompress')) {
//启用数据压缩
$content = gzuncompress($content);
}
return unserialize($content);
}
return $default;
}
示例9: 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;
}
示例10: 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);
}
}
}
示例11: get
/**
* 读取缓存
* @access public
* @param string $name 缓存变量名
* @return mixed
*/
public function get($name)
{
$name = $this->options['prefix'] . sqlite_escape_string($name);
$sql = 'SELECT value FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\' AND (expire=0 OR expire >' . time() . ') LIMIT 1';
$result = sqlite_query($this->handler, $sql);
if (sqlite_num_rows($result)) {
$content = sqlite_fetch_single($result);
if (function_exists('gzcompress')) {
//启用数据压缩
$content = gzuncompress($content);
}
return unserialize($content);
}
return false;
}
示例12: getLabel
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;
}
}
示例13: save
/**
* Guarda un elemento en la cache con nombre $id y valor $value
*
* @param string $id
* @param string $group
* @param string $value
* @param int $lifetime tiempo de vida en forma timestamp de unix
* @return boolean
*/
public function save($id, $group, $value, $lifetime)
{
if ($lifetime == null) {
$lifetime = 'undefined';
}
$id = addslashes($id);
$group = addslashes($group);
$value = addslashes($value);
$result = sqlite_query($this->_db, " SELECT COUNT(*) FROM cache WHERE id='{$id}' AND \"group\"='{$group}' ");
$count = sqlite_fetch_single($result);
/**
* Ya existe el elemento cacheado
*
**/
if ($count) {
return sqlite_exec($this->_db, " UPDATE cache SET value='{$value}', lifetime='{$lifetime}' WHERE id='{$id}' AND \"group\"='{$group}' ");
}
return sqlite_exec($this->_db, " INSERT INTO cache (id, \"group\", value, lifetime) VALUES ('{$id}','{$group}','{$value}','{$lifetime}') ");
}
示例14: _handle
/**
* Handles the page write event and removes the database info
* when the plugin code is no longer in the source
*/
function _handle(&$event, $param)
{
$data = $event->data;
if (strpos($data[0][1], 'dataentry') !== false) {
return;
}
// plugin seems still to be there
$sqlite = $this->dthlp->_getDB();
if (!$sqlite) {
return;
}
$id = ltrim($data[1] . ':' . $data[2], ':');
// get page id
$res = $sqlite->query('SELECT pid FROM pages WHERE page = ?', $id);
$pid = (int) sqlite_fetch_single($res);
if (!$pid) {
return;
}
// we have no data for this page
$sqlite->query('DELETE FROM data WHERE pid = ?', $pid);
$sqlite->query('DELETE FROM pages WHERE pid = ?', $pid);
}
示例15: _clean
/**
* Clean some cache records
*
* Available modes are :
* Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
* Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
* Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
* ($tags can be an array of strings or a single string)
* Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
* ($tags can be an array of strings or a single string)
*
* @param string $mode Clean mode
* @param array $tags Array of tags
* @return boolean True if no problem
*/
private function _clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
{
if ($mode == Zend_Cache::CLEANING_MODE_ALL) {
$res1 = $this->_query('DELETE FROM cache');
$res2 = $this->_query('DELETE FROM tag');
return $res1 && $res2;
}
if ($mode == Zend_Cache::CLEANING_MODE_OLD) {
$mktime = time();
$res1 = $this->_query("DELETE FROM tag WHERE id IN (SELECT id FROM cache WHERE expire>0 AND expire<={$mktime})");
$res2 = $this->_query("DELETE FROM cache WHERE expire>0 AND expire<={$mktime}");
return $res1 && $res2;
}
if ($mode == Zend_Cache::CLEANING_MODE_MATCHING_TAG) {
$first = true;
$ids = array();
foreach ($tags as $tag) {
$res = $this->_query("SELECT DISTINCT(id) AS id FROM tag WHERE name='{$tag}'");
if (!$res) {
return false;
}
$rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
$ids2 = array();
foreach ($rows as $row) {
$ids2[] = $row['id'];
}
if ($first) {
$ids = $ids2;
$first = false;
} else {
$ids = array_intersect($ids, $ids2);
}
}
$result = true;
foreach ($ids as $id) {
$result = $result && $this->remove($id);
}
return $result;
}
if ($mode == Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG) {
$res = $this->_query("SELECT id FROM cache");
$rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
$result = true;
foreach ($rows as $row) {
$id = $row['id'];
$matching = false;
foreach ($tags as $tag) {
$res = $this->_query("SELECT COUNT(*) AS nbr FROM tag WHERE name='{$tag}' AND id='{$id}'");
if (!$res) {
return false;
}
$nbr = (int) @sqlite_fetch_single($res);
if ($nbr > 0) {
$matching = true;
}
}
if (!$matching) {
$result = $result && $this->remove($id);
}
}
return $result;
}
return false;
}