protected function getPDO($name)
    {
        if (!isset($this->config[$name]) || !is_array($this->config[$name])) {
            throw new \Exception('Config not found ! (config: ' . $name . ')');
        }

        $config = $this->config[$name];

        if (!isset($config['dsn'])) {
            throw new \Exception('"dsn" parameter is not defined !');
        }

        if (!isset($config['user'])) {
            throw new \Exception('"user" parameter is not defined !');
        }

        if (!isset($config['pass'])) {
            throw new \Exception('"pass" parameter is not defined !');
        }

        $config['options'] = isset($config['options']) ? $config['options'] : array();

        $options = array();
        foreach ($config['options'] as $name => $value) {
            if (0 === strpos($name, 'PDO::')) {
                $options[constant($name)] = $value;
            }
        }

        $connection = new \PDO($config['dsn'], $config['user'], $config['pass'], $options);
        $connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

        return $connection;
    }
protected function getPDO($name)
    {
        if (!isset($this->config[$name]) || !is_array($this->config[$name])) {
            throw new \Exception('Config not found ! (config: ' . $name . ')');
        }

        $config = $this->config[$name];

        if (!isset($config['dsn'])) {
            throw new \Exception('"dsn" parameter is not defined !');
        }

        if (!isset($config['user'])) {
            throw new \Exception('"user" parameter is not defined !');
        }

        if (!isset($config['pass'])) {
            throw new \Exception('"pass" parameter is not defined !');
        }

        $config['options'] = isset($config['options']) ? $config['options'] : array();

        $options = array();
        foreach ($config['options'] as $name => $value) {
            if (0 === strpos($name, 'PDO::')) {
                $options[constant($name)] = $value;
            }
        }

        $connection = new \PDO($config['dsn'], $config['user'], $config['pass'], $options);
        $connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

        return $connection;
    }
protected function getPDO ( $ name ) { if ( ! isset ( $ this -> config [ $ name ] ) || ! is_array ( $ this -> config [ $ name ] ) ) { throw new \ Exception ( 'Config not found ! (config: ' . $ name . ')' ) ; } $ config = $ this -> config [ $ name ] ; if ( ! isset ( $ config [ 'dsn' ] ) ) { throw new \ Exception ( '"dsn" parameter is not defined !' ) ; } if ( ! isset ( $ config [ 'user' ] ) ) { throw new \ Exception ( '"user" parameter is not defined !' ) ; } if ( ! isset ( $ config [ 'pass' ] ) ) { throw new \ Exception ( '"pass" parameter is not defined !' ) ; } $ config [ 'options' ] = isset ( $ config [ 'options' ] ) ? $ config [ 'options' ] : array ( ) ; $ options = array ( ) ; foreach ( $ config [ 'options' ] as $ name => $ value ) { if ( 0 === strpos ( $ name , 'PDO::' ) ) { $ options [ constant ( $ name ) ] = $ value ; } } $ connection = new \ PDO ( $ config [ 'dsn' ] , $ config [ 'user' ] , $ config [ 'pass' ] , $ options ) ; $ connection -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; return $ connection ; }
Create new PDO connection

@param  string $name Config name
@return \PDO
@throws \Exception
Create new PDO connection