/** * @file * Test sqlite availability. */ function error($message) { global $db; sqlite_close($db); unlink('test.db'); die($message); }
function close() { if ($this->sqlite) { sqlite_close($this->sqlite); $this->sqlite = null; } }
function CreateDatabase(&$db, $name) { if (!function_exists("sqlite_open")) { return $db->SetError("Connect", "SQLite support is not available in this PHP configuration"); } $database_file = $db->GetDatabaseFile($name); if (@file_exists($database_file)) { return $db->SetError("Create database", "database already exists"); } @touch($database_file); if (!@file_exists($database_file)) { return $db->SetError("Create database", "Unable to create new database. Permission denied"); } $mode = isset($db->options["AccessMode"]) ? strcmp($db->options["AccessMode"][0], "0") ? intval($db->options["AccessMode"]) : octdec($db->options["AccessMode"]) : 0640; @chmod($database_file, $mode); if (!is_readable($database_file)) { @unlink($database_file); return $db->SetError("Create database", "Unable to open database for Reading. Permission denied"); } if (!is_writable($database_file)) { @unlink($database_file); return $db->SetError("Create database", "Unable to open database for Writing. Permission denied"); } $handle = @sqlite_open($database_file, $mode); if (!$handle) { @unlink($database_file); return $db->SetError("Create database", isset($php_errormsg) ? $php_errormsg : "could not create the database file"); } sqlite_close($handle); return 1; }
function sql_close() { if (!$this->db_connect_id) { return false; } return @sqlite_close($this->db_connect_id); }
function disconnect() { //DBとの接続を切断する。 $flag = 1; sqlite_close($this->link) or $flag = false; return $flag; }
/** * @return SQLite **/ public function disconnect() { if ($this->isConnected()) { sqlite_close($this->link); } return $this; }
/** * Initializes and opens the database * * Needs to be called right after loading this helper plugin */ function init($dbname, $updatedir) { global $conf; // check for already open DB if ($this->db) { if ($this->dbname == $dbname) { // db already open return true; } // close other db sqlite_close($this->db); $this->db = null; $this->dbname = ''; } $this->dbname = $dbname; $dbfile = $conf['metadir'] . '/' . $dbname . '.sqlite'; $init = !@file_exists($dbfile) || (int) @filesize($dbfile) < 3; $error = ''; $this->db = sqlite_open($dbfile, 0666, $error); if (!$this->db) { msg("SQLite: failed to open SQLite " . $this->dbname . " database ({$error})", -1); return false; } // register our custom aggregate function sqlite_create_aggregate($this->db, 'group_concat', array($this, '_sqlite_group_concat_step'), array($this, '_sqlite_group_concat_finalize'), 2); $this->_updatedb($init, $updatedir); return true; }
function close() { if (!is_null($this->db)) { sqlite_close($this->db); } $this->db = null; }
public function prepareDB($bWithData = true) { if (file_exists(dirname(__FILE__) . '/unittest.db')) { unlink(dirname(__FILE__) . '/unittest.db'); } $db = sqlite_open(dirname(__FILE__) . '/unittest.db'); $res = sqlite_query($db, 'CREATE TABLE people (id INTEGER PRIMARY KEY, firstName TEXT, lastName TEXT)', $sError); if ($res === false) { throw new Exception($sError); } if ($bWithData) { $res = sqlite_query($db, 'INSERT INTO people (id,firstName,lastName) VALUES (1, \'Jerome\', \'Piochet\')', $sError); if ($res === false) { throw new Exception($sError); } $res = sqlite_query($db, 'INSERT INTO people (id,firstName,lastName) VALUES (2, \'Tadao\', \'Poichet\')', $sError); if ($res === false) { throw new Exception($sError); } $res = sqlite_query($db, 'INSERT INTO people (id,firstName,lastName) VALUES (3, \'A\', \'B\')', $sError); if ($res === false) { throw new Exception($sError); } $res = sqlite_query($db, 'INSERT INTO people (id,firstName,lastName) VALUES (4, \'C\', \'D\')', $sError); if ($res === false) { throw new Exception($sError); } } sqlite_close($db); }
function disconnect() { if (is_resource($this->connectionId)) { sqlite_close($this->connectionId); $this->connectionId = null; } }
public function dbclose() { if ($this->db != -1) { sqlite_close($this->db); $db = -1; } }
private function Disconnect() { if (!is_null($this->link)) { return sqlite_close($this->link); } return false; }
function close() { if ($this->handler) { return sqlite_close($this->handler); } else { die('データベースハンドラが見つかりません。'); } }
public static function close() { // garbage collect once in a hundred page requests if (rand(1, 100) == 100) { Session::cleanup(); } return @sqlite_close(SESSION_DB_LINK); }
public function Close() { if ($this->connection === false) { throw new DatabaseEx('Not connected to a database server!'); } sqlite_close($this->connection); $this->connection = null; }
function close() { if ($this->db == null) { return; } sqlite_close($this->db); $this->db = null; }
function close() { if ($this->conn) { @sqlite_close($this->conn); return true; } return false; }
function disconnect() { if (!$this->link_identifier || $this->persistent) { return; } @sqlite_close($this->link_identifier); $this->link_identifier = false; }
function closeConn($db) { if (IS_SQLITE3) { $db->close(); } else { sqlite_close($db); } }
/** * デストラクタ。 */ function __destruct() { if ($this->transaction > 0) { $this->query('ROLLBACK'); } if ($this->link != false) { sqlite_close($this->link); } }
public function Disconnect() { if ($this->type == DatabaseType::Sqlite) { sqlite_close($this->dblink); } if ($this->type == DatabaseType::MySql) { $this->dblink->close(); } }
public function disconnect() { $this->errString = null; if (!$this->isConnected()) { return; } sqlite_close($this->oDB); $this->oDB = null; }
function delete($what, $from, $where, $id, $database) { $delete_sql = "DELETE FROM " . $from . " WHERE " . $where . " = \"" . $id . "\""; if (!sqlite_query($database, $delete_sql, SQLITE_ASSOC, $sqliteerror)) { sqlite_close($database); die("Database error: " . $sqliteerror); } echo '<p>' . $what . ' removed.</p>'; }
/** * This function closes an open connection. * * @access public * @override * @return boolean whether an open connection was closed */ public function close() { if ($this->is_connected()) { if (!@sqlite_close($this->resource)) { return FALSE; } $this->resource = NULL; } return TRUE; }
function __construct($opt) { parent::__construct($opt); if (!file_exists($opt['path'])) { $db = sqlite_open($opt['path']); sqlite_query($db, 'CREATE TABLE data (key, value, created);'); sqlite_close($db); } $this->db = sqlite_open($opt['path']); }
function set_pfhost_nonwritable($name) { global $database; $db = sqlite_popen($database); $results = sqlite_query("select * from pfhosts where name='" . sqlite_escape_string($name) . "'", $db); $pfhost_check = sqlite_fetch_array($results, SQLITE_ASSOC); if ($pfhost_check['can_connect'] == "true") { $results = sqlite_query("update pfhosts set can_connect='false' where name='" . sqlite_escape_string($name) . "'", $db); } sqlite_close($db); }
function getAllContents($file) { $db = sqlite_open($file); $rs = sqlite_query('SELECT * FROM trans_unit', $db); $result = ''; while ($row = sqlite_fetch_array($rs, SQLITE_NUM)) { $result .= implode(', ', $row) . "\n"; } sqlite_close($db); return $result; }
function Close() { if ($this->connection != 0) { if (isset($this->supported["Transactions"]) && !$this->auto_commit) { $this->AutoCommitTransactions(1); } sqlite_close($this->connection); $this->connection = 0; $this->affected_rows = -1; } }
function disconnect() { parent::disconnect(); if ($this->db != null) { @sqlite_close($this->db); $this->_afterDisconnect(); return true; } else { $this->_addError('Not connected to a db!', 'disconnect()'); return false; } }
function init_fixtures($temp) { $db = sqlite_open($temp); sqlite_query('CREATE TABLE catalogue (cat_id INTEGER PRIMARY KEY, name VARCHAR NOT NULL, source_lang VARCHAR, target_lang VARCHAR, date_created INT, date_modified INT, author VARCHAR);', $db); sqlite_query('CREATE TABLE trans_unit (msg_id INTEGER PRIMARY KEY, cat_id INTEGER NOT NULL DEFAULT \'1\', id VARCHAR, source TEXT, target TEXT, comments TEXT, date_added INT, date_modified INT, author VARCHAR, translated INT(1) NOT NULL DEFAULT \'0\');', $db); sqlite_query("INSERT INTO catalogue (cat_id, name) VALUES (1, 'messages.fr_FR')", $db); sqlite_query("INSERT INTO catalogue (cat_id, name) VALUES (2, 'messages.it')", $db); sqlite_query("INSERT INTO trans_unit (msg_id, cat_id, id, source, target, translated) VALUES (1, 1, 1, 'an english sentence', 'une phrase en français', 1)", $db); sqlite_query("INSERT INTO trans_unit (msg_id, cat_id, id, source, target, translated) VALUES (2, 1, 2, 'another english sentence', 'une autre phrase en français', 1)", $db); sqlite_close($db); return sfMessageSource::factory('SQLite', 'sqlite://localhost/' . $temp); }