本文整理汇总了PHP中SQLite3::open方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLite3::open方法的具体用法?PHP SQLite3::open怎么用?PHP SQLite3::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite3
的用法示例。
在下文中一共展示了SQLite3::open方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
/**
* Establishes a connection to the defined database.
*
* @return void
*/
public function connect()
{
if ($this->connected === TRUE) {
return;
}
if ($this->configuration['db']['driver'] != 'sqlite3') {
$this->logger->error('Cannot connect to a non-sqlite3 database connection!');
return;
}
$flag = $this->readonly ? SQLITE3_OPEN_READONLY : SQLITE3_OPEN_READWRITE;
$this->sqlite3->open($this->db, $flag | SQLITE3_OPEN_CREATE, '');
if ($this->sqlite3->lastErrorCode() === 0) {
$this->connected = TRUE;
}
}
示例2: open
/**
* @param $db_filename = string fullpath to db-file
* @param $access_mode = integer [ 0 = readonly | 1 = writeable | 2 = createIfNotExist ] default in parent is 3 (writeable + createIfNotExist)
**/
public function open($db_filename, $access_mode = 0, $encryptionKey = '')
{
$create = false;
switch ($access_mode) {
case 3:
case 2:
$mode = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE;
$create = true;
break;
case 1:
$mode = SQLITE3_OPEN_READWRITE;
break;
default:
$mode = SQLITE3_OPEN_READONLY;
break;
}
// first check for file
if (!$create && !file_exists($db_filename) || !$create && $mode == 0 && !is_readable($db_filename) || !$create && $mode == 1 && (!is_writable($db_filename) || !is_readable($db_filename))) {
return false;
}
// open file
$this->fn = $db_filename;
parent::open($db_filename, $mode, $encryptionKey);
// check if file is a valid db
$check = @parent::querySingle('SELECT count(*) FROM sqlite_master');
$code = @parent::lastErrorCode();
if (0 < $check || 0 == $check && 0 == $code) {
return true;
} else {
$this->errormsg = parent::lastErrorMsg();
return false;
}
}
示例3: db_connect
/**
* Non-persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_connect()
{
//if ( ! $conn_id = @sqlite_open(, FILE_WRITE_MODE, $error))
if (!($conn_id = @SQLite3::open($this->database, $error))) {
log_message('error', $error);
if ($this->db_debug) {
$this->display_error($error, '', TRUE);
}
return FALSE;
}
return $conn;
}
示例4: catch
<?php
try {
$db = new SQLite3(__DIR__ . '/db1.db');
$db->open(__DIR__ . '/db1.db');
} catch (Exception $ex) {
var_dump($ex->getMessage());
}
@unlink(__DIR__ . '/db1.db');
示例5: __construct
public function __construct($filename='http_sessions.db'){
$this->savePath = ini_get('session.save_path'). DIRECTORY_SEPARATOR .$filename;
$this->dbHandle = parent::open($this->savePath);}