summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorRick Ellis <rick.ellis@ellislab.com>2008-10-07 02:44:41 +0200
committerRick Ellis <rick.ellis@ellislab.com>2008-10-07 02:44:41 +0200
commitb6ba6a3a8ef3d594ff3f32f2d128a8211f1d2db3 (patch)
tree060df12096676944b2aaad9d9b8952595535a27e /system
parent2cad6e9da8b94833503d0d2f545bcaa29d50bd5d (diff)
Added support for empty connection strings, based on bug # 3135
Diffstat (limited to 'system')
-rw-r--r--system/database/drivers/postgre/postgre_driver.php39
1 files changed, 32 insertions, 7 deletions
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 55f650280..aada164d0 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -39,16 +39,43 @@ class CI_DB_postgre_driver extends CI_DB {
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 @@ class CI_DB_postgre_driver extends CI_DB {
*/
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());
}
// --------------------------------------------------------------------