Ejemplo n.º 1
0
 /**
  * Parse configuration array into options for PDO constructor.
  *
  * http://pecl.php.net/bugs/7234
  * Setting a bogus socket does not appear to work.
  *
  * @throws  Horde_Db_Exception
  * @return  array  [dsn, username, password]
  */
 protected function _parseConfig()
 {
     $this->_config['adapter'] = 'mysql';
     if (isset($this->_config['port'])) {
         if (empty($this->_config['host'])) {
             $msg = 'host is required if port is specified';
             throw new Horde_Db_Exception($msg);
         }
         if (preg_match('/[^\\d\\.]/', $this->_config['host'])) {
             $msg = 'pdo_mysql ignores port unless IP address is used for host';
             throw new Horde_Db_Exception($msg);
         }
     }
     return parent::_parseConfig();
 }
Ejemplo n.º 2
0
 /**
  * Connect to the db
  */
 public function connect()
 {
     parent::connect();
     $this->_connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
     $retval = $this->_connection->exec('PRAGMA full_column_names=0');
     if ($retval === false) {
         $error = $this->_connection->errorInfo();
         throw new Horde_Db_Exception($error[2]);
     }
     $retval = $this->_connection->exec('PRAGMA short_column_names=1');
     if ($retval === false) {
         $error = $this->_connection->errorInfo();
         throw new Horde_Db_Exception($error[2]);
     }
     $this->_sqliteVersion = $this->selectValue('SELECT sqlite_version(*)');
 }
Ejemplo n.º 3
0
 /**
  * Get the appropriate DML object and call the parent constructor.
  *
  * @param array $options Connection options.
  */
 public function __construct($options = array())
 {
     parent::__construct($options);
 }
Ejemplo n.º 4
0
 /**
  * Parse configuration array into options for PDO constructor.
  *
  * @throws  Horde_Db_Exception
  * @return  array  [dsn, username, password]
  */
 protected function _parseConfig()
 {
     $this->_config['adapter'] = 'pgsql';
     return parent::_parseConfig();
 }