API CHANGE: Added getParameters() to PostgreSQLDatabase

API CHANGE: Added 'port' parameter to PostgreSQLDatabase
This commit is contained in:
Sam Minnee 2010-04-13 04:42:36 +00:00
parent b59ce20a97
commit 9e8cc03243

View File

@ -87,13 +87,15 @@ class PostgreSQLDatabase extends SS_Database {
$dbName=$parameters['database']; $dbName=$parameters['database'];
else $dbName=$this->database; else $dbName=$this->database;
$port = empty($parameters['port']) ? 5432 : $parameters['port'];
//First, we need to check that this database exists. To do this, we will connect to the 'postgres' database first //First, we need to check that this database exists. To do this, we will connect to the 'postgres' database first
$this->dbConn = pg_connect('host=' . $parameters['server'] . ' port=5432 dbname=postgres' . $username . $password); $this->dbConn = pg_connect('host=' . $parameters['server'] . ' port=' . $port . ' dbname=postgres' . $username . $password);
if(!$this->databaseExists($dbName)) if(!$this->databaseExists($dbName))
$this->createDatabase($dbName); $this->createDatabase($dbName);
//Now we can be sure that this database exists, so we can connect to it //Now we can be sure that this database exists, so we can connect to it
$this->dbConn = pg_connect('host=' . $parameters['server'] . ' port=5432 dbname=' . $dbName . $username . $password); $this->dbConn = pg_connect('host=' . $parameters['server'] . ' port=' . $port . ' dbname=' . $dbName . $username . $password);
//By virtue of getting here, the connection is active: //By virtue of getting here, the connection is active:
$this->active=true; $this->active=true;
@ -113,6 +115,13 @@ class PostgreSQLDatabase extends SS_Database {
return null; return null;
} }
/**
* Return the parameters used to construct this database connection
*/
public function getParameters() {
return $this->parameters;
}
/** /**
* Returns true if this database supports collations * Returns true if this database supports collations
* TODO: get rid of this? * TODO: get rid of this?