本文整理汇总了PHP中sqlite_popen函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlite_popen函数的具体用法?PHP sqlite_popen怎么用?PHP sqlite_popen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlite_popen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: db_connect
/**
* Non-persistent database connection.
*
* @param bool $persistent
*
* @return resource
*/
public function db_connect($persistent = false)
{
$error = null;
$conn_id = $persistent === true ? sqlite_popen($this->database, 0666, $error) : sqlite_open($this->database, 0666, $error);
isset($error) && log_message('error', $error);
return $conn_id;
}
示例2: sql_connect
/**
* {@inheritDoc}
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->server = $sqlserver . ($port ? ':' . $port : '');
$this->dbname = $database;
$error = '';
if ($this->persistency) {
if (!function_exists('sqlite_popen')) {
$this->connect_error = 'sqlite_popen function does not exist, is sqlite extension installed?';
return $this->sql_error('');
}
$this->db_connect_id = @sqlite_popen($this->server, 0666, $error);
} else {
if (!function_exists('sqlite_open')) {
$this->connect_error = 'sqlite_open function does not exist, is sqlite extension installed?';
return $this->sql_error('');
}
$this->db_connect_id = @sqlite_open($this->server, 0666, $error);
}
if ($this->db_connect_id) {
@sqlite_query('PRAGMA short_column_names = 1', $this->db_connect_id);
// @sqlite_query('PRAGMA encoding = "UTF-8"', $this->db_connect_id);
}
return $this->db_connect_id ? true : array('message' => $error);
}
示例3: sql_db
function sql_db($sqlserver, $trash, $trash, $trash, $persistency = true)
{
$this->persistency = $persistency;
$this->server = $sqlserver;
$this->db_connect_id = $this->persistency ? @sqlite_popen($this->server, 0666, $sqliteerror) : @sqlite_open($this->server, 0666, $sqliteerror);
return $this->db_connect_id ? $this->db_connect_id : false;
}
示例4: dblayer
function dblayer($db_host, $db_user, $db_pass, $db_name, $p_connect = false)
{
// Support SQLite
if (!function_exists('sqlite_open')) {
exit('This PHP environment doesn\'t have SQLite support built in. SQLite support is required if you want to use a SQLite database to run this forum. Consult the PHP documentation for further assistance.');
}
// Prepend $db_name with the path to the forum root directory
$db_name = EPS_ROOT . $db_name;
if (!file_exists($db_name)) {
@touch($db_name);
@chmod($db_name, 0666);
if (!file_exists($db_name)) {
error('Unable to create new database \'' . $db_name . '\'. Permission denied', __FILE__, __LINE__);
}
}
if (!is_readable($db_name)) {
error('Unable to open database \'' . $db_name . '\' for reading. Permission denied', __FILE__, __LINE__);
}
if (!is_writable($db_name)) {
error('Unable to open database \'' . $db_name . '\' for writing. Permission denied', __FILE__, __LINE__);
}
if ($p_connect) {
$this->link_id = @sqlite_popen($db_name, 0666, $sqlite_error);
} else {
$this->link_id = @sqlite_open($db_name, 0666, $sqlite_error);
}
if (!$this->link_id) {
error('Unable to open database \'' . $db_name . '\'. SQLite reported: ' . $sqlite_error, __FILE__, __LINE__);
} else {
return $this->link_id;
}
}
示例5: connect
/**
* Connects to a database.
* @return void
* @throws DibiException
*/
public function connect(array &$config)
{
DibiConnection::alias($config, 'database', 'file');
$this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
$this->fmtDateTime = isset($config['formatDateTime']) ? $config['formatDateTime'] : 'U';
$errorMsg = '';
if (isset($config['resource'])) {
$this->connection = $config['resource'];
} elseif (empty($config['persistent'])) {
$this->connection = @sqlite_open($config['database'], 0666, $errorMsg);
// intentionally @
} else {
$this->connection = @sqlite_popen($config['database'], 0666, $errorMsg);
// intentionally @
}
if (!$this->connection) {
throw new DibiDriverException($errorMsg);
}
$this->buffered = empty($config['unbuffered']);
$this->dbcharset = empty($config['dbcharset']) ? 'UTF-8' : $config['dbcharset'];
$this->charset = empty($config['charset']) ? 'UTF-8' : $config['charset'];
if (strcasecmp($this->dbcharset, $this->charset) === 0) {
$this->dbcharset = $this->charset = NULL;
}
}
示例6: __construct
function __construct($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect)
{
// Prepend $db_name with the path to the forum root directory
$db_name = LUNA_ROOT . $db_name;
$this->prefix = $db_prefix;
if (!file_exists($db_name)) {
@touch($db_name);
@chmod($db_name, 0666);
if (!file_exists($db_name)) {
error('Unable to create new database \'' . $db_name . '\'. Permission denied', __FILE__, __LINE__);
}
}
if (!is_readable($db_name)) {
error('Unable to open database \'' . $db_name . '\' for reading. Permission denied', __FILE__, __LINE__);
}
if (!forum_is_writable($db_name)) {
error('Unable to open database \'' . $db_name . '\' for writing. Permission denied', __FILE__, __LINE__);
}
if ($p_connect) {
$this->link_id = @sqlite_popen($db_name, 0666, $sqlite_error);
} else {
$this->link_id = @sqlite_open($db_name, 0666, $sqlite_error);
}
if (!$this->link_id) {
error('Unable to open database \'' . $db_name . '\'. SQLite reported: ' . $sqlite_error, __FILE__, __LINE__);
} else {
return $this->link_id;
}
}
示例7: connect
public function connect()
{
if ($this->_connection) {
return;
}
// Extract the connection parameters, adding required variabels
extract($this->_config['connection'] + array('database' => '', 'persistent' => FALSE));
try {
if ($persistent) {
// Create a persistent connection
$this->_connection = sqlite_popen($database);
} else {
// Create a connection and force it to be a new link
$this->_connection = sqlite_open($database);
}
} catch (Exception $e) {
// No connection exists
$this->_connection = NULL;
throw new Database_Exception(':error', array(':error' => $e->getMessage()), $e->getCode());
}
$this->_connection_id = sha1($dsn);
if (!empty($this->_config['connection']['variables'])) {
// Set session variables
$variables = array();
foreach ($this->_config['connection']['variables'] as $var => $val) {
$variables[] = 'SESSION ' . $var . ' = ' . $this->quote($val);
}
sqlite_query('SET ' . implode(', ', $variables), $this->_connection);
}
}
示例8: db_connect
/**
* Non-persistent database connection
*
* @param bool $persistent
* @return resource
*/
public function db_connect($persistent = FALSE)
{
$error = NULL;
$conn_id = $persistent === TRUE ? sqlite_popen($this->database, 0666, $error) : sqlite_open($this->database, 0666, $error);
isset($error) && log_message('error', $error);
return $conn_id;
}
示例9: connect
public function connect($config = array())
{
$this->config = $config;
$this->connect = $this->config['pconnect'] === true ? @sqlite_popen($this->config['database'], 0666, $error) : @sqlite_open($this->config['database'], 0666, $error);
if (!empty($error)) {
die(getErrorMessage('Database', 'mysqlConnectError'));
}
}
示例10: vdict_open
function vdict_open($fn)
{
global $dberror;
if (function_exists('sqlite_popen')) {
return sqlite_popen($fn, 0666, $dberror);
}
return new PDO('sqlite:' . $fn);
}
示例11: sql_connect
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port, $persistency = false)
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->server = $sqlserver . ($port ? ':' . $port : '');
$this->dbname = $database;
$this->db_connect_id = $this->persistency ? @sqlite_popen($this->server, 0, $error) : @sqlite_open($this->server, 0, $error);
return $this->db_connect_id ? true : $error;
}
示例12: connect
public function connect($a)
{
if (!empty($a['persistent'])) {
$db1 = sqlite_popen($a['dbname']);
} else {
$db1 = sqlite_open($a['dbname']);
}
return $db1;
}
示例13: db_pconnect
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
if (!($conn_id = sqlite_popen($this->database, 0666, $error))) {
log_message('error', $error);
if ($this->db_debug) {
$this->display_error($error, '', TRUE);
}
}
return $conn_id;
}
示例14: set_pfhost_nonwritable
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);
}
示例15: db_pconnect
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
if (!($conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error))) {
log_message('error', $error);
if ($this->db_debug) {
$this->display_error($error, '', TRUE);
}
return FALSE;
}
return $conn_id;
}