Horde_Db_Adapter_Pdo_Base::_parseConfig PHP Method

_parseConfig() protected method

Parse configuration array into options for PDO constructor.
protected _parseConfig ( ) : array
return array [dsn, username, password]
    protected function _parseConfig()
    {
        $this->_checkRequiredConfig(array('adapter', 'username'));
        // try an empty password if it's not set.
        if (!isset($this->_config['password'])) {
            $this->_config['password'] = '';
        }
        // collect options to build PDO Data Source Name (DSN) string
        $dsnOpts = $this->_config;
        unset($dsnOpts['adapter'], $dsnOpts['username'], $dsnOpts['password'], $dsnOpts['protocol'], $dsnOpts['persistent'], $dsnOpts['charset'], $dsnOpts['phptype'], $dsnOpts['socket']);
        // return DSN and user/pass for connection
        return array($this->_buildDsnString($this->_normalizeConfig($dsnOpts)), $this->_config['username'], $this->_config['password']);
    }

Usage Example

Example #1
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';
     // PDO for PostgreSQL does not accept a socket argument
     // in the connection string; the location can be set via the
     // "host" argument instead.
     if (!empty($this->_config['socket'])) {
         $this->_config['host'] = $this->_config['socket'];
         unset($this->_config['socket']);
     }
     return parent::_parseConfig();
 }