public function getConnection($conparams)
    {
        $conparams = $this->prepareParams($conparams);

        if (!isset($conparams['dsn'])) {
            throw new InvalidArgumentException('No dsn specified in your connection parameters');
        }

        $dsn      = $conparams['dsn'];
        $user     = isset($conparams['user']) ? $conparams['user'] : null;
        $password = isset($conparams['password']) ? $conparams['password'] : null;

        // load any driver options from the config file
        // driver options are those PDO settings that have to be passed during the connection construction
        $driver_options = [];
        if (isset($conparams['options']) && is_array($conparams['options'])) {
            foreach ($conparams['options'] as $option => $optiondata) {
                $value = $optiondata;
                if (is_string($value) && false !== strpos($value, '::')) {
                    if (!defined($value)) {
                        throw new InvalidArgumentException(sprintf('Error processing driver options for dsn "%s"', $dsn));
                    }
                    $value = constant($value);
                }
                $driver_options[$option] = $value;
            }
        }

        try {
            $con = new PdoConnection($dsn, $user, $password, $driver_options);
            $this->initConnection($con, isset($conparams['settings']) && is_array($conparams['settings']) ? $conparams['settings'] : []);
        } catch (\PDOException $e) {
            throw new AdapterException("Unable to open PDO connection", 0, $e);
        }

        return $con;
    }
public function getConnection($conparams)
    {
        $conparams = $this->prepareParams($conparams);

        if (!isset($conparams['dsn'])) {
            throw new InvalidArgumentException('No dsn specified in your connection parameters');
        }

        $dsn      = $conparams['dsn'];
        $user     = isset($conparams['user']) ? $conparams['user'] : null;
        $password = isset($conparams['password']) ? $conparams['password'] : null;

        // load any driver options from the config file
        // driver options are those PDO settings that have to be passed during the connection construction
        $driver_options = [];
        if (isset($conparams['options']) && is_array($conparams['options'])) {
            foreach ($conparams['options'] as $option => $optiondata) {
                $value = $optiondata;
                if (is_string($value) && false !== strpos($value, '::')) {
                    if (!defined($value)) {
                        throw new InvalidArgumentException(sprintf('Error processing driver options for dsn "%s"', $dsn));
                    }
                    $value = constant($value);
                }
                $driver_options[$option] = $value;
            }
        }

        try {
            $con = new PdoConnection($dsn, $user, $password, $driver_options);
            $this->initConnection($con, isset($conparams['settings']) && is_array($conparams['settings']) ? $conparams['settings'] : []);
        } catch (\PDOException $e) {
            throw new AdapterException("Unable to open PDO connection", 0, $e);
        }

        return $con;
    }
public function getConnection ( $ conparams ) { $ conparams = $ this -> prepareParams ( $ conparams ) ; if ( ! isset ( $ conparams [ 'dsn' ] ) ) { throw new InvalidArgumentException ( 'No dsn specified in your connection parameters' ) ; } $ dsn = $ conparams [ 'dsn' ] ; $ user = isset ( $ conparams [ 'user' ] ) ? $ conparams [ 'user' ] : null ; $ password = isset ( $ conparams [ 'password' ] ) ? $ conparams [ 'password' ] : null ; // load any driver options from the config file // driver options are those PDO settings that have to be passed during the connection construction $ driver_options = [ ] ; if ( isset ( $ conparams [ 'options' ] ) && is_array ( $ conparams [ 'options' ] ) ) { foreach ( $ conparams [ 'options' ] as $ option => $ optiondata ) { $ value = $ optiondata ; if ( is_string ( $ value ) && false !== strpos ( $ value , '::' ) ) { if ( ! defined ( $ value ) ) { throw new InvalidArgumentException ( sprintf ( 'Error processing driver options for dsn "%s"' , $ dsn ) ) ; } $ value = constant ( $ value ) ; } $ driver_options [ $ option ] = $ value ; } } try { $ con = new PdoConnection ( $ dsn , $ user , $ password , $ driver_options ) ; $ this -> initConnection ( $ con , isset ( $ conparams [ 'settings' ] ) && is_array ( $ conparams [ 'settings' ] ) ? $ conparams [ 'settings' ] : [ ] ) ; } catch ( \ PDOException $ e ) { throw new AdapterException ( "Unable to open PDO connection" , 0 , $ e ) ; } return $ con ; }
Build database connection

@param array $conparams connection parameters

@return PdoConnection

@throws InvalidArgumentException
@throws AdapterException
Build database connection