Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 10 additions and 7 deletions.
  1. +10 −7 code/PostgreSQLDatabase.php
View
17 code/PostgreSQLDatabase.php
@@ -133,21 +133,24 @@ function connectDatabase(){
if(!$parameters)
return false;
- ($parameters['username']!='') ? $username=' user=' . $parameters['username'] : $username='';
- ($parameters['password']!='') ? $password=' password=\'' . $parameters['password'] . '\'' : $password='';
+ (!empty($parameters['username'])) ? $username=' user=' . $parameters['username'] : $username='';
+ (!empty($parameters['password'])) ? $password=' password=' . $parameters['password'] : $password='';
if(!isset($this->database))
$dbName=$parameters['database'];
else $dbName=$this->database;
-
- $port = empty($parameters['port']) ? 5432 : $parameters['port'];
-
+
+ $port = empty($parameters['port']) ? 5432 : $parameters['port'];
+ (!empty($parameters['server'])) ? $server=' host=' . $parameters['server'] . ' port=' . $port : $server='';
+
+
// First, we need to check that this database exists. To do this, we will connect to the 'postgres' database first
// some setups prevent access to this database so set PostgreSQLDatabase::$check_database_exists = false
if(self::$check_database_exists) {
// Close the old connection
if($this->dbConn) pg_close($this->dbConn);
- $this->dbConn = pg_connect('host=' . $parameters['server'] . ' port=' . $port . ' dbname=postgres' . $username . $password);
+ $this->dbConn = pg_connect($server . ' dbname=postgres' . $username . $password);
+
if(!$this->dbConn) {
throw new ErrorException("Couldn't connect to PostgreSQL database");
@@ -164,7 +167,7 @@ function connectDatabase(){
if($this->dbConn) pg_close($this->dbConn);
//Now we can be sure that this database exists, so we can connect to it
- $this->dbConn = pg_connect('host=' . $parameters['server'] . ' port=' . $port . ' dbname=' . $dbName . $username . $password);
+ $this->dbConn = pg_connect($server . ' dbname=' . $dbName . $username . $password);
if(!$this->dbConn) {
throw new ErrorException("Couldn't connect to PostgreSQL database");

No commit comments for this range

Something went wrong with that request. Please try again.