Skip to content

Commit

Permalink
Added PostgreSQL support for non-standard ports (Issue #4152).
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe136 committed Aug 23, 2014
1 parent 6732a89 commit 816d1c2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libraries/joomla/database/driver/postgresql.php
Expand Up @@ -115,8 +115,16 @@ public function connect()
throw new RuntimeException('PHP extension pg_connect is not available.');
}

// Fix database with port connection
$e_host = $this->options['host'];
if(strpos($e_host, ':')) {
list($e_host, $port)=explode(':', $e_host, 2);
} else {
$port=false;
}

// Build the DSN for the connection.
$dsn = "host={$this->options['host']} dbname={$this->options['database']} user={$this->options['user']} password={$this->options['password']}";
$dsn = "host='$e_host' port='$port' dbname={$this->options['database']} user={$this->options['user']} password={$this->options['password']}";

// Attempt to connect to the server.
if (!($this->connection = @pg_connect($dsn)))
Expand Down

0 comments on commit 816d1c2

Please sign in to comment.