Esempio n. 1
0
 public function __construct(array $config = array())
 {
     parent::__construct($config);
     if (isset($config['db']) && is_resource($config['db'])) {
         $this->db = $config['db'];
     } else {
         $config['host'] = $this->_($config, 'host', null);
         $config['user'] = $this->_($config, 'user', null);
         $config['password'] = $this->_($config, 'password', null);
         $config['new_link'] = (bool) $this->_($config, 'new_link', false);
         $config['client_flags'] = $this->_($config, 'client_flags', 0);
         if ($this->_($config, 'persistent')) {
             $this->db = mysql_pconnect($config['host'], $config['user'], $config['password'], $config['client_flags']);
         } else {
             $this->db = mysql_connect($config['host'], $config['user'], $config['password'], $config['new_link'], $config['client_flags']);
         }
         if ($this->db == false) {
             throw new AleExceptionCache(mysql_error(), mysql_errno());
         }
         if (isset($config['database'])) {
             $result = mysql_select_db($config['database'], $this->db);
             if ($result === false) {
                 throw new AleExceptionCache(mysql_error($this->db), mysql_errno($this->db));
             }
         }
     }
 }
Esempio n. 2
0
 public function __construct(array $config = array())
 {
     parent::__construct($config);
     if (isset($config['adodb_dir'])) {
         require_once $config['adodb_dir'] . DIRECTORY_SEPARATOR . 'adodb.inc.php';
     }
     if ($config['adodb_error'] == 'exception') {
         require_once ADODB_DIR . DIRECTORY_SEPARATOR . 'adodb-exceptions.inc.php';
     }
     if (!defined('_ADODB_LAYER')) {
         throw new AleExceptionCache('ADOdb layer not defined');
     }
     if (isset($config['db']) && is_resource($config['db'])) {
         $this->db = $config['db'];
     } else {
         if (!isset($config['dsn'])) {
             throw new AleExceptionCache('ADOdb dsn (Data Source Name) config missing');
         }
         $this->db = ADONewConnection($config['dsn']);
         if ($this->db == false) {
             throw new AleExceptionCache('ADODb connection failed');
         }
     }
     $this->nameQuote = $this->db->nameQuote;
 }
Esempio n. 3
0
 public function __construct(array $config = array())
 {
     parent::__construct($config);
     if (isset($config['db']) && is_object($config['db'])) {
         $this->db = $config['db'];
     } else {
         $this->db = JFactory::getDBO();
     }
 }
Esempio n. 4
0
 public function __construct(array $config = array())
 {
     parent::__construct($config);
     if (isset($config['db']) && is_resource($config['db'])) {
         $this->db = $config['db'];
     } else {
         $config['host'] = $this->_($config, 'host', null);
         $config['port'] = $this->_($config, 'port', null);
         $config['database'] = $this->_($config, 'database', null);
         $config['user'] = $this->_($config, 'user', null);
         $config['password'] = $this->_($config, 'password', null);
         $config['new_link'] = (bool) $this->_($config, 'new_link', false);
         $connection_string = "host='" . $config['host'] . "' " . "port='" . $config['port'] . "' " . "dbname='" . $config['database'] . "' " . "user='******'user'] . "' " . "password='******'password'] . "' ";
         if ($this->_($config, 'persistent')) {
             $this->db = pg_pconnect($connection_string, $config['new_link']);
         } else {
             $this->db = pg_connect($connection_string, $config['new_link']);
         }
         if ($this->db == false) {
             throw new AleExceptionCache(pg_last_error(), pg_connection_status());
         }
     }
 }