Ruckusing_Adapter_PgSQL_Base::db_connect PHP Method

db_connect() private method

Connect to the db
private db_connect ( string $dsn ) : boolean
$dsn string the current dsn
return boolean
    private function db_connect($dsn)
    {
        if (!function_exists('pg_connect')) {
            throw new Ruckusing_Exception("\nIt appears you have not compiled PHP with Postgres support: missing function pg_connect()", Ruckusing_Exception::INVALID_CONFIG);
        }
        $db_info = $this->get_dsn();
        if ($db_info) {
            $this->db_info = $db_info;
            $conninfo = sprintf('host=%s port=%s dbname=%s user=%s password=%s', $db_info['host'], !empty($db_info['port']) ? $db_info['port'] : '5432', $db_info['database'], $db_info['user'], $db_info['password']);
            $this->conn = pg_connect($conninfo);
            if ($this->conn === FALSE) {
                throw new Ruckusing_Exception("\n\nCould not connect to the DB, check host / user / password\n\n", Ruckusing_Exception::INVALID_CONFIG);
            }
            return true;
        } else {
            throw new Ruckusing_Exception("\n\nCould not extract DB connection information from: {$dsn}\n\n", Ruckusing_Exception::INVALID_CONFIG);
        }
    }