src/Native5/Core/Database/DB.php
private function _connect()
    {
        if (empty($this->_config))
            throw new \Exception('Empty connection settings provided'); 
        
        $port = $this->_config->getPort();
        $port = !empty($port) ? $port : 3306;
        $dsn = $this->_config->getType().':host='.$this->_config->getHost().';port='.$port.';dbname='.$this->_config->getName();
        // Create a PDO Instance for this user + database combination
        try {
            $this->_conn = new \PDO($dsn, $this->_config->getUser(), $this->_config->getPassword());
        } catch(\PDOException $pe) {
            throw new \RuntimeException("Cannot connect to DB '".$this->_config->getName().
                "' with user '".$this->_config->getUser()."'".PHP_EOL."Message: ".$pe->getMessage());
        }

        $this->_conn->setAttribute(\PDO::ATTR_PERSISTENT, false);
        $this->_conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
        $this->_conn->setAttribute(\PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'UTF8'");
        $this->_conn->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
        $this->_conn->setAttribute(\PDO::ATTR_ORACLE_NULLS, \PDO::NULL_TO_STRING);
        $this->_conn->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
    }
private function _connect()
    {
        if (empty($this->_config))
            throw new \Exception('Empty connection settings provided'); 
        
        $port = $this->_config->getPort();
        $port = !empty($port) ? $port : 3306;
        $dsn = $this->_config->getType().':host='.$this->_config->getHost().';port='.$port.';dbname='.$this->_config->getName();
        // Create a PDO Instance for this user + database combination
        try {
            $this->_conn = new \PDO($dsn, $this->_config->getUser(), $this->_config->getPassword());
        } catch(\PDOException $pe) {
            throw new \RuntimeException("Cannot connect to DB '".$this->_config->getName().
                "' with user '".$this->_config->getUser()."'".PHP_EOL."Message: ".$pe->getMessage());
        }

        $this->_conn->setAttribute(\PDO::ATTR_PERSISTENT, false);
        $this->_conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
        $this->_conn->setAttribute(\PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'UTF8'");
        $this->_conn->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
        $this->_conn->setAttribute(\PDO::ATTR_ORACLE_NULLS, \PDO::NULL_TO_STRING);
        $this->_conn->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
    }
private function _connect ( ) { if ( empty ( $ this -> _config ) ) throw new \ Exception ( 'Empty connection settings provided' ) ; $ port = $ this -> _config -> getPort ( ) ; $ port = ! empty ( $ port ) ? $ port : 3306 ; $ dsn = $ this -> _config -> getType ( ) . ':host=' . $ this -> _config -> getHost ( ) . ';port=' . $ port . ';dbname=' . $ this -> _config -> getName ( ) ; // Create a PDO Instance for this user + database combination try { $ this -> _conn = new \ PDO ( $ dsn , $ this -> _config -> getUser ( ) , $ this -> _config -> getPassword ( ) ) ; } catch ( \ PDOException $ pe ) { throw new \ RuntimeException ( "Cannot connect to DB '" . $ this -> _config -> getName ( ) . "' with user '" . $ this -> _config -> getUser ( ) . "'" . PHP_EOL . "Message: " . $ pe -> getMessage ( ) ) ; } $ this -> _conn -> setAttribute ( \ PDO :: ATTR_PERSISTENT , false ) ; $ this -> _conn -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; $ this -> _conn -> setAttribute ( \ PDO :: MYSQL_ATTR_INIT_COMMAND , "SET NAMES 'UTF8'" ) ; $ this -> _conn -> setAttribute ( \ PDO :: ATTR_DEFAULT_FETCH_MODE , \ PDO :: FETCH_ASSOC ) ; $ this -> _conn -> setAttribute ( \ PDO :: ATTR_ORACLE_NULLS , \ PDO :: NULL_TO_STRING ) ; $ this -> _conn -> setAttribute ( \ PDO :: ATTR_EMULATE_PREPARES , true ) ; }
_connect Make the PDO connection

@access private
@return void
_connect Make the PDO connection