Added support for empty connection strings, based on bug # 3135
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 55f6502..aada164 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -39,16 +39,43 @@
 	var $_random_keyword = ' RANDOM()'; // database specific random keyword

 

 	/**

+	 * Connection String

+	 *

+	 * @access	private

+	 * @return	string

+	 */	

+	function _connect_string()

+	{

+		$components = array(

+								'hostname'	=> 'host',

+								'port'		=> 'port',

+								'database'	=> 'dbname',

+								'username'	=> 'user',

+								'password'	=> 'password'

+							);

+		

+		$connect_string = "";

+		foreach ($components as $key => $val)

+		{

+			if (isset($this->$key) && $this->$key != '')

+			{

+				$connect_string .= " $val=".$this->$key;

+			}

+		}

+		return trim($connect_string);

+	}

+

+	// --------------------------------------------------------------------

+

+	/**

 	 * Non-persistent database connection

 	 *

 	 * @access	private called by the base class

 	 * @return	resource

 	 */	

 	function db_connect()

-	{

-		$port = ($this->port == '') ? '' : " port=".$this->port;

-		

-		return @pg_connect("host=".$this->hostname.$port." dbname=".$this->database." user=".$this->username." password=".$this->password);

+	{		

+		return @pg_connect($this->_connect_string());

 	}

 

 	// --------------------------------------------------------------------

@@ -61,9 +88,7 @@
 	 */	

 	function db_pconnect()

 	{

-		$port = ($this->port == '') ? '' : " port=".$this->port;

-

-		return @pg_pconnect("host=".$this->hostname.$port." dbname=".$this->database." user=".$this->username." password=".$this->password);

+		return @pg_pconnect($this->_connect_string());

 	}

 	

 	// --------------------------------------------------------------------