Пример #1
0
 /**
  * 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
0
 /**
  * {@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
0
 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
0
 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;
     }
 }
 /**
  * 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
0
 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
0
 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
0
 /**
  * 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
0
 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
0
function vdict_open($fn)
{
    global $dberror;
    if (function_exists('sqlite_popen')) {
        return sqlite_popen($fn, 0666, $dberror);
    }
    return new PDO('sqlite:' . $fn);
}
Пример #11
0
 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
0
 public function connect($a)
 {
     if (!empty($a['persistent'])) {
         $db1 = sqlite_popen($a['dbname']);
     } else {
         $db1 = sqlite_open($a['dbname']);
     }
     return $db1;
 }
 /**
  * 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
0
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);
}
 /**
  * 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;
 }
Пример #16
0
Файл: SQLite.php Проект: mmr/b1n
 private function Connect($config_file)
 {
     if ($this->IsConnected()) {
         throw new Exception("Already connected to DB.");
     }
     require_once $config_file;
     if ($this->link = sqlite_popen(DBConfig::$FILE, DBConfig::$MODE, $error)) {
         return true;
     } else {
         throw new Exception("Could not connect to DB : {$error}.");
     }
 }
 /**
  * @return SQLite
  **/
 public function connect()
 {
     if ($this->persistent) {
         $this->link = sqlite_popen($this->basename);
     } else {
         $this->link = sqlite_open($this->basename);
     }
     if (!$this->link) {
         throw new DatabaseException('can not open SQLite base: ' . sqlite_error_string(sqlite_last_error($this->link)));
     }
     return $this;
 }
Пример #18
0
 /**
  * (non-PHPdoc)
  *
  * @see Core_DB::connect()
  */
 public function connect()
 {
     if ($this->config['pconnect'] == 1) {
         $this->link = sqlite_popen($this->config['database'], $this->config['mode']);
     } else {
         $this->link = sqlite_open($this->config['database'], $this->config['mode']);
     }
     if (!$this->link) {
         throw new Base_Exception(sqlite_error_string());
     }
     return $this->link;
 }
 /**
  * Selects a SQLite database.
  */
 protected function selectDatabase()
 {
     $errorMessage = '';
     if ($this->usePConnect) {
         $this->linkID = @sqlite_popen($this->database, 0666, $errorMessage);
     } else {
         $this->linkID = @sqlite_open($this->database, 0666, $errorMessage);
     }
     if ($this->linkID === false) {
         throw new DatabaseException("Cannot use database " . $this->database . "\n" . $errorMessage, $this);
     }
 }
Пример #20
0
 /**
  * 连接数据库
  * 
  * @param      string     $dbhost 数据库服务器地址
  * @param      string     $dbuser 数据库用户名
  * @param      string     $dbpass 数据库密码
  * @param      string     $dbname 数据库名
  * @param      bool       $selectdb 是否选中当前数据库
  * @access     public
  * @return     bool
  */
 function connect($dbhost = '', $dbuser = '', $dbpass = '', $dbname = '', $selectdb = true)
 {
     if (JIEQI_DB_PCONNECT == 1) {
         $this->conn = @sqlite_open($dbname, 0666, $sqliteerror);
     } else {
         $this->conn = @sqlite_popen($dbname, 0666, $sqliteerror);
     }
     if (!$this->conn) {
         return false;
     } else {
         return true;
     }
 }
Пример #21
0
 /**
  * Connect to server
  */
 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 = '';
     $this->db_connect_id = $this->persistency ? @sqlite_popen($this->server, 0666, $error) : @sqlite_open($this->server, 0666, $error);
     if ($this->db_connect_id) {
         @sqlite_query('PRAGMA short_column_names = 1', $this->db_connect_id);
     }
     return $this->db_connect_id ? true : array('message' => $error);
 }
Пример #22
0
Файл: SQLite.php Проект: mmr/b1n
 /**
  * Connect to the database.
  * @param $configFile configuration file.
  */
 private function connect($configFile)
 {
     if ($this->isConnected()) {
         throw new CouldNotConnectException("Already connected to DB.");
     }
     require_once $configFile;
     $error = "";
     if ($this->link = sqlite_popen(DBConfig::$FILE, DBConfig::$MODE, $error)) {
         return true;
     } else {
         throw new CouldNotConnectException($error);
     }
 }
Пример #23
0
 /**
  * Make a Connect to the mysql Server
  *
  * @param string $host
  * @param string $user
  * @param string $pass
  * @param string $db
  * @param string $schema not required
  * @param string $enconding not required
  * @return mixed return connection resource
  */
 function connect($host, $user, $pass, $db, $schema = "", $encoding = "")
 {
     if ($this->CLASS['config']->db->pconnect) {
         $this->connection = sqlite_popen($db, $this->mode);
     } else {
         $this->connection = sqlite_open($db, $this->mode);
     }
     if (!$this->connection) {
         $this->CLASS['error']->log("Cannnot connect to host!", 1, "class-sqlite.php::connect");
         exit;
     }
     return $this->connection;
 }
Пример #24
0
 function connect()
 {
     $errstr = '';
     if ($this->params['persistent']) {
         $this->conn = sqlite_popen($this->params['file'], 0644, $errstr);
     } else {
         $this->conn = sqlite_open($this->params['file'], 0644, $errstr);
     }
     if (!$this->conn) {
         $this->_catch("Unable to connect to the database: {$errstr}");
         return false;
     }
     return true;
 }
Пример #25
0
 public function connect($sHost, $sUser, $sPass, $sName, $sPort = false, $sPersistent = false)
 {
     if ($sPort) {
         $sHost = $sHost . ':' . $sPort;
     }
     $this->_hMaster = $sPersistent ? @sqlite_popen($sHost, 0666, $sError) : @sqlite_open($sHost, 0666, $sError);
     // Unable to connect to master
     if (!$this->_hMaster) {
         // Cannot connect to the database
         return Phpfox_Error::set('Cannot connect to the database: ' . $sError);
     }
     $this->_hSlave =& $this->_hMaster;
     return true;
 }
Пример #26
0
 protected function real_connect()
 {
     $filename = $this->settings['filename'];
     $mode = $this->settings['mode'];
     $error = null;
     if ($this->settings['persistent']) {
         $this->connection_handle = sqlite_popen($filename, $mode, $error);
     } else {
         $this->connection_handle = sqlite_open($filename, $mode, $error);
     }
     if (!$this->connection_handle || $error) {
         throw new AnewtDatabaseConnectionException($error);
     }
 }
Пример #27
0
 public function __construct($dbinfo)
 {
     if (isset($dbinfo['dbname'])) {
         if (!$dbinfo['persistent']) {
             $this->connection = sqlite_open($dbinfo['dbname'], 0666, $errormessage);
         } else {
             $this->connection = sqlite_popen($dbinfo['dbname'], 0666, $errormessage);
         }
         if (!$this->connection) {
             throw new Exception($errormessage);
         }
     } else {
         throw new Exception("You must supply database name for a successful connection");
     }
 }
Пример #28
0
 function connect($host, $db, $user, $password, $persistent = false)
 {
     parent::connect($host, $db, $user, $password, $persistent);
     if ($persistent) {
         $this->db = sqlite_open($db);
     } else {
         $this->db = sqlite_popen($db);
     }
     if ($this->db) {
         return true;
     } else {
         $this->error = "Error connecting to db!";
         return false;
     }
 }
Пример #29
0
 function connect($_DB)
 {
     $this->pre = $_DB['prefix'];
     if ($this->pconnect) {
         $this->conn = sqlite_popen(INC_P . '/data/' . $_DB['database'], 0666, $sqliteerror);
     } else {
         $this->conn = sqlite_open(INC_P . '/data/' . $_DB['database'], 0666, $sqliteerror);
     }
     if (!$this->conn) {
         var_dump($sqliteerror);
         $this->halt("Can not connect SQLite Database");
     }
     if ($_DB['charset']) {
         @sqlite_unbuffered_query("SET NAMES '" . $_DB['charset'] . "'");
     }
     return true;
 }
 function connect($dbPath)
 {
     if (DEBUG) {
         if ($dbPath == ':memory:') {
             $this->connId = sqlite_popen($dbPath, 0666, $this->error);
         } else {
             $this->connId = sqlite_open($dbPath, 0666, $this->error);
         }
     } else {
         if ($dbPath == ':memory:') {
             $this->connId = @sqlite_popen($dbPath, 0666, $this->error);
         } else {
             $this->connId = @sqlite_popen($dbPath, 0666, $this->error);
         }
     }
     return $this->connId;
 }