コード例 #1
2
 /**
  * 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;
     }
 }
コード例 #2
0
ファイル: db_sqlite.php プロジェクト: rust1989/edit
 function num_rows($query_id = "")
 {
     if ($query_id == "") {
         $query_id = $this->query_id;
     }
     return @sqlite_num_rows($query_id);
 }
コード例 #3
0
ファイル: SQLiteStorage.php プロジェクト: phpsmith/IS4C
 public function set($key, $val, $immutable = false)
 {
     if ($immutable) {
         $this->immutableSet($key, $val);
     } else {
         if (empty($val)) {
             sqlite_query($this->db, "DELETE FROM is4c_local WHERE keystr='{$key}'");
         } else {
             if (is_array($val)) {
                 $temp = "";
                 foreach ($val as $v) {
                     $temp .= $v . chr(255);
                 }
                 $val = substr($temp, 0, strlen($temp) - 1);
             } elseif ($val === false) {
                 $val = 'FALSE';
             } elseif ($val === true) {
                 $val = 'TRUE';
             }
             $check = sqlite_query($this->db, "SELECT valstr FROM is4c_local WHERE keystr='{$key}'");
             if (sqlite_num_rows($check) == 0) {
                 sqlite_query($this->db, "INSERT INTO is4c_local VALUES ('{$key}','{$val}')");
             } else {
                 sqlite_query($this->db, "UPDATE is4c_local SET valstr='{$val}' WHERE keystr='{$key}'");
             }
         }
     }
     $this->debug();
 }
コード例 #4
0
ファイル: Sqlite.php プロジェクト: TheProjecter/skeleton
 /**
  * Returns the number of rows in the recordset
  *
  * @return int
  */
 public function numRows()
 {
     if ($this->result) {
         return sqlite_num_rows($this->result);
     } else {
         return 0;
     }
 }
コード例 #5
0
ファイル: Result.class.php プロジェクト: google2013/myqeecms
 protected function total_count()
 {
     $count = @sqlite_num_rows($this->_result);
     if (!$count > 0) {
         $count = 0;
     }
     return $count;
 }
コード例 #6
0
 /**
  * @see ResultSet::getRecordCount()
  */
 public function getRecordCount()
 {
     $rows = @sqlite_num_rows($this->result);
     if ($rows === null) {
         throw new SQLException("Error fetching num rows", sqlite_error_string(sqlite_last_error($this->conn->connection)));
     }
     return (int) $rows;
 }
コード例 #7
0
ファイル: session.php プロジェクト: laiello/php-garden
 public static function write($id, $data)
 {
     $id = "'" . sqlite_escape_string($id) . "'";
     $expire = time() + 2 * WEEK;
     $R = sqlite_query("SELECT id FROM sess WHERE id = {$id}", SESSION_DB_LINK);
     sqlite_query(sqlite_num_rows($R) ? "UPDATE sess SET data = '{$data}', expire = {$expire} WHERE id = {$id}" : "INSERT INTO sess (id, data, expire) VALUES ({$id}, '{$data}', {$expire})", SESSION_DB_LINK);
     return sqlite_changes(SESSION_DB_LINK) ? true : false;
 }
コード例 #8
0
 public function count()
 {
     $lastresult = $this->results[$this->lasthash];
     //print_r($this->results);
     $count = sqlite_num_rows($lastresult);
     if (!$count) {
         $count = 0;
     }
     return $count;
 }
コード例 #9
0
ファイル: helpers.php プロジェクト: Alamantus/PHP-App-Base
function num_rows($query_results)
{
    if (DATABASE_TYPE == "mysql") {
        $num_rows = mysqli_num_rows($query_results);
    } elseif (DATABASE_TYPE == "sqlite") {
        $num_rows = sqlite_num_rows($query_results);
    } elseif (DATABASE_TYPE == "pgsql") {
        $num_rows = pg_num_rows($query_results);
    }
    return $num_rows;
}
コード例 #10
0
ファイル: sqlite.php プロジェクト: rotvulpix/php-nuke
 function sql_numrows($query_id = 0)
 {
     if (!$query_id) {
         $query_id = $this->query_result;
     }
     if ($query_id) {
         return @sqlite_num_rows($query_id);
     } else {
         return false;
     }
 }
コード例 #11
0
 public function getLength()
 {
     if ($this->r === true) {
         return sqlite_changes($this->r);
     } else {
         if ($this->r === false) {
             return 0;
         }
     }
     return sqlite_num_rows($this->r);
 }
コード例 #12
0
ファイル: sql_num_rows.php プロジェクト: eodivision/eoCMS
function sql_num_rows($data)
{
    if (defined('DB_TYPE')) {
        if (DB_TYPE == 'mysql') {
            $sql = mysql_num_rows($data);
        } elseif (DB_TYPE == 'sqlite') {
            $sql = sqlite_num_rows($data);
        }
        return $sql;
    }
}
コード例 #13
0
 function checkCredentials($userid, $password, Request $message)
 {
     $db = new dbHandler();
     $link = $db->getDbHandler();
     $query = "SELECT * FROM Security WHERE UserName = '******' and Password = '******'";
     $result = sqlite_query($link, $query);
     if (sqlite_num_rows($result) < 1) {
         $db->close();
         throw new WebORBAuthenticationException("invalid userid or password");
     }
     $db->close();
 }
コード例 #14
0
 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;
     }
 }
コード例 #15
0
 public function cookielogin()
 {
     if (isset($_COOKIE['userid']) && isset($_COOKIE['pass'])) {
         $id = sqlite_escape_string($_COOKIE['userid']);
         $pass = sqlite_escape_string($_COOKIE['pass']);
         $q = sqlite_query($this->db, "SELECT * FROM users WHERE uid = '{$id}' AND password = '******' LIMIT 1", $e);
         if (sqlite_num_rows($q) > 0) {
             $r = sqlite_fetch_array($q);
             $_SESSION['uid'] = $r['uid'];
             $_SESSION['uname'] = $r['username'];
         }
     }
 }
コード例 #16
0
ファイル: sqlite.class.php プロジェクト: Lovinity/EQM
 /**
  * Performs sql query with error reporting and logging.
  * 
  * @todo Debug debug backtrace
  * @access public
  * @param  string $sSql query string
  * @return int query result handle
  */
 public function query($sSql, &$hLink = '')
 {
     if (!$hLink) {
         $hLink =& $this->_hMaster;
     }
     PHPFOX_DEBUG ? Phpfox_Debug::start('sql') : '';
     $hRes = sqlite_query($sSql, $hLink);
     if (!$hRes) {
         Phpfox_Error::trigger('Query Error:' . $this->_sqlError(), PHPFOX_DEBUG ? E_USER_ERROR : E_USER_WARNING);
     }
     PHPFOX_DEBUG ? Phpfox_Debug::end('sql', array('sql' => $sSql, 'slave' => $this->_sIsSlave, 'rows' => is_bool($hRes) ? '-' : sqlite_num_rows($hRes))) : '';
     $this->_sIsSlave = '';
     return $hRes;
 }
コード例 #17
0
ファイル: sqliteAdapter.php プロジェクト: nimigeanu/hollow
 /**
  * Constructor method for the adapter.  This constructor implements the setting of the
  * 3 required properties for the object.
  * 
  * @param resource $d The datasource resource
  */
 function sqliteAdapter($d)
 {
     parent::RecordSetAdapter($d);
     // grab all of the rows
     $fieldcount = sqlite_num_fields($d);
     // loop over all of the fields
     for ($i = 0; $i < $fieldcount; $i++) {
         // decode each field name ready for encoding when it goes through serialization
         // and save each field name into the array
         $this->columns[] = sqlite_field_name($d, $i);
     }
     if (sqlite_num_rows($d) > 0) {
         $this->rows = sqlite_fetch_all($d, SQLITE_NUM);
     }
 }
コード例 #18
0
ファイル: Sqlite.php プロジェクト: xuyi5918/ipensoft
 /**
  * 读取缓存
  * @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;
 }
コード例 #19
0
ファイル: Sqlite.php プロジェクト: HXFY/think
 /**
  * 读取缓存
  * @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;
 }
コード例 #20
0
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;
}
コード例 #21
0
 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;
 }
コード例 #22
0
ファイル: Sqlite.php プロジェクト: TheProjecter/skeleton
 protected function _query($sql)
 {
     $result = sqlite_query($this->_connection, $sql);
     $error = sqlite_last_error($this->_connection);
     $this->_errorHandler($error, $error != 0 ? sqlite_error_string($error) : '');
     if ($result && $this->queryHasResultSet($sql)) {
         $this->_numRows = sqlite_num_rows($result);
         $resultObject = $this->createRecordsetObject();
         $resultObject->setResult($result);
     } else {
         $this->_numRows = sqlite_changes($this->_connection);
         $resultObject = $this->createResultObject();
     }
     return $resultObject;
 }
コード例 #23
0
ファイル: SessionStoreSqlite.php プロジェクト: kwdwkiss/trial
 public function write($sessID, $sessData)
 {
     $newExp = time() + $this->lifeTime;
     $res = sqlite_query("SELECT * FROM {$this->tableName}\n                           WHERE session_id = '{$sessID}'", $this->dbHandle);
     if (sqlite_num_rows($res)) {
         sqlite_exec("UPDATE {$this->tableName}\n                        SET session_expires = '{$newExp}',\n                        session_data = '{$sessData}'\n                        WHERE session_id = '{$sessID}'", $this->dbHandle);
         if (sqlite_changes($this->dbHandle)) {
             return true;
         }
     } else {
         sqlite_exec("INSERT INTO {$this->tableName} (\n                        session_id,\n                        session_expires,\n                        session_data)\n                        VALUES(\n                        '{$sessID}',\n                        '{$newExp}',\n                        '{$sessData}')", $this->dbHandle);
         if (sqlite_changes($this->dbHandle)) {
             return true;
         }
     }
     return false;
 }
コード例 #24
0
ファイル: SHP.class.php プロジェクト: hardkap/pritlog
 function load_plugins($from_folder = './plugins/')
 {
     global $config;
     //$from_folder = getcwd();
     //echo $from_folder.'<br>';
     if ($handle = @opendir($from_folder)) {
         while (false !== ($file = readdir($handle))) {
             if (is_file($from_folder . $file)) {
                 if (strpos($from_folder . $file, '.plugin.php') != false && strpos($from_folder . $file, '.svn-base') == false) {
                     $pluginid1 = explode(".", $file);
                     $pluginid = $pluginid1[0];
                     //echo $pluginid.'<br>';
                     $result = sqlite_query($config['db'], "select status from plugins WHERE id = '{$pluginid}';");
                     $status = 0;
                     while ($row = sqlite_fetch_array($result, SQLITE_ASSOC)) {
                         $status = $row['status'];
                     }
                     if (isset($_POST['notfirst'])) {
                         if ($_POST[$pluginid] == 1) {
                             $status = 1;
                         } else {
                             $status = 0;
                         }
                     }
                     $this->plugins[$file]['found'] = true;
                     //echo $pluginid."  ".$status."  ".sqlite_num_rows($result)."<br>";
                     if (sqlite_num_rows($result) == 0) {
                         $this->plugins[$file]['found'] = false;
                     }
                     $this->plugins[$file]['active'] = false;
                     if ($status == 1) {
                         $this->plugins[$file]['active'] = true;
                     }
                     //require_once $from_folder . $file;
                     require_once $from_folder . $file;
                     $this->plugins[$file]['file'] = $file;
                 }
             } else {
                 if (is_dir($from_folder . $file) && $file != '.' && $file != '..') {
                     $this->load_plugins($from_folder . $file . '/');
                 }
             }
         }
         closedir($handle);
     }
 }
コード例 #25
0
ファイル: Result.php プロジェクト: chrismcmacken/phptools
 /**
  * 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);
     }
 }
コード例 #26
0
ファイル: ifs.php プロジェクト: RicterZ/pixmicat
 function openIndex()
 {
     if (extension_loaded('pdo_sqlite')) {
         $this->backend = 'pdo_sqlite';
         $this->index = new PDO('sqlite:' . $this->logfile);
         if ($this->index->query("SELECT COUNT(name) FROM sqlite_master WHERE name LIKE 'IndexFS'")->fetchColumn() === '0') {
             $this->init();
         }
     } else {
         if (extension_loaded('SQLite')) {
             $this->backend = 'sqlite2';
             $this->index = sqlite_open($this->logfile, 0666);
             if (sqlite_num_rows(sqlite_query($this->index, "SELECT name FROM sqlite_master WHERE name LIKE 'IndexFS'")) === 0) {
                 $this->init();
             }
         } else {
             $this->backend = 'log';
             $this->modified = false;
             if (!file_exists($this->logfile)) {
                 $this->init();
                 return;
             }
             if (filesize($this->logfile) == 0) {
                 return;
             }
             $indexlog = file($this->logfile);
             $indexlog_count = count($indexlog);
             // 讀入索引檔並計算目前筆數
             $this->index = array();
             for ($i = 0; $i < $indexlog_count; $i++) {
                 if (!($trimline = rtrim($indexlog[$i]))) {
                     continue;
                 }
                 // 本行無意義
                 $field = explode("\t\t", $trimline);
                 $this->index[$field[0]] = array('imgSize' => $field[1], 'imgURL' => isset($field[2]) ? $field[2] : '');
                 // 索引格式: 檔名	檔案大小	對應路徑
             }
             $this->keylist = array_keys($this->index);
             unset($indexlog);
         }
     }
     PMCLibrary::getLoggerInstance(__CLASS__)->info('Backend: %s, Path: %s', $this->backend, $this->logfile);
 }
コード例 #27
0
ファイル: tags.php プロジェクト: speed47/plugin-blogtng
 /**
  * Load tags for specified pid
  */
 function load($pid)
 {
     $this->pid = trim($pid);
     $query = 'SELECT tag FROM tags WHERE pid = ? ORDER BY tag ASC';
     $resid = $this->sqlitehelper->query($query, $this->pid);
     if ($resid === false) {
         msg('blogtng plugin: failed to load tags!', -1);
         $this->tags = array();
     }
     if (sqlite_num_rows($resid) == 0) {
         $this->tags = array();
     }
     $tags_from_db = $this->sqlitehelper->res2arr($resid);
     $tags = array();
     foreach ($tags_from_db as $tag_from_db) {
         array_push($tags, $tag_from_db['tag']);
     }
     $this->tags = $tags;
 }
コード例 #28
0
 public function isExpired($key)
 {
     $mintime = time();
     $data = sqlite_query("SELECT * FROM cache WHERE marker='{$key}' AND valid>={$mintime}", $this->cachedb);
     $row = sqlite_fetch_array($data, SQLITE_ASSOC);
     if (sqlite_num_rows($data) == 0) {
         $this->cache[$key] == "__expired__";
         return true;
     }
     if ($row['expired'] == '1') {
         $this->cache[$key] == "__expired__";
         return true;
     }
     //die(print_r(unserialize($row['content'])));
     $_temp = unserialize($row['content']);
     $this->cache[$key] = $_temp[$key];
     //die($this->cache[$key]);
     return false;
 }
コード例 #29
0
ファイル: pio.sqlite.php プロジェクト: Kennyl/pixmicat
    function dbInit($isAddInitData = true)
    {
        $this->dbPrepare();
        if (sqlite_num_rows(sqlite_query($this->con, "SELECT name FROM sqlite_master WHERE name LIKE '" . $this->tablename . "'")) === 0) {
            // 資料表不存在
            $result = 'CREATE TABLE ' . $this->tablename . ' (
	"no" INTEGER  NOT NULL PRIMARY KEY,
	"resto" INTEGER  NOT NULL,
	"root" TIMESTAMP DEFAULT \'0\' NOT NULL,
	"time" INTEGER  NOT NULL,
	"md5chksum" VARCHAR(32)  NOT NULL,
	"category" VARCHAR(255)  NOT NULL,
	"tim" INTEGER  NOT NULL,
	"ext" VARCHAR(4)  NOT NULL,
	"imgw" INTEGER  NOT NULL,
	"imgh" INTEGER  NOT NULL,
	"imgsize" VARCHAR(10)  NOT NULL,
	"tw" INTEGER  NOT NULL,
	"th" INTEGER  NOT NULL,
	"pwd" VARCHAR(8)  NOT NULL,
	"now" VARCHAR(255)  NOT NULL,
	"name" VARCHAR(255)  NOT NULL,
	"email" VARCHAR(255)  NOT NULL,
	"sub" VARCHAR(255)  NOT NULL,
	"com" TEXT  NOT NULL,
	"host" VARCHAR(255)  NOT NULL,
	"status" VARCHAR(255)  NOT NULL
	);';
            // PIO Structure V3
            $idx = array('resto', 'root', 'time');
            foreach ($idx as $x) {
                $result .= 'CREATE INDEX IDX_' . $this->tablename . '_' . $x . ' ON ' . $this->tablename . '(' . $x . ');';
            }
            $result .= 'CREATE INDEX IDX_' . $this->tablename . '_resto_no ON ' . $this->tablename . '(resto,no);';
            if ($isAddInitData) {
                $result .= 'INSERT INTO ' . $this->tablename . ' (resto,root,time,md5chksum,category,tim,ext,imgw,imgh,imgsize,tw,th,pwd,now,name,email,sub,com,host,status) VALUES (0, datetime("now"), 1111111111, "", "", 1111111111111, "", 0, 0, "", 0, 0, "", "05/01/01(六)00:00", "' . $this->ENV['NONAME'] . '", "", "' . $this->ENV['NOTITLE'] . '", "' . $this->ENV['NOCOMMENT'] . '", "", "");';
            }
            sqlite_exec($this->con, $result);
            // 正式新增資料表
            $this->dbCommit();
        }
    }
コード例 #30
0
ファイル: Sqlite.php プロジェクト: hubs/yuncms
 /**
  * (non-PHPdoc)
  *
  * @see Core_DB::query()
  */
 public function query($str, $key = '')
 {
     $this->query_str = $this->parse_prefix($str);
     // 自动替换表前缀
     if (!is_resource($this->link)) {
         $this->connect();
     }
     N('db_query', 1);
     // 记录开始执行时间
     G('queryStartTime');
     $this->lastqueryid = sqlite_query($this->link, $this->query_str);
     $this->debug();
     if (false === $this->lastqueryid) {
         $this->error();
         return false;
     } else {
         $this->num_rows = sqlite_num_rows($this->lastqueryid);
         return $this->get_all($key);
     }
 }