From 928d83ce1590f14aadfa7a1805c00bb84bd9ef1c Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 13 Feb 2012 14:07:57 -0500 Subject: Refixed Old-style pdo connection string --- system/database/drivers/pdo/pdo_driver.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 5991586c7..c5940ddc8 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -116,15 +116,12 @@ class CI_DB_pdo_driver extends CI_DB { // hostname generally would have this prototype // $db['hostname'] = 'pdodriver:host(/Server(/DSN))=hostname(/DSN);'; // We need to get the prefix (pdodriver used by PDO). - $this->dsn = $this->hostname; - $this->pdodriver = current(explode(':', $this->hostname)); + $dsnarray = explode(':', $this->hostname); + $this->pdodriver = $dsnarray[0]; // End dsn with a semicolon for extra backward compability // if database property was not empty. - if ( ! empty($this->database)) - { - $this->dsn .= rtrim($this->dsn, ';').';'; - } + $this->dsn .= rtrim($this->hostname, ';').';'; } else { @@ -139,7 +136,9 @@ class CI_DB_pdo_driver extends CI_DB { $this->dsn = $this->pdodriver.':'; // Add hostname to the DSN for databases that need it - if ( ! empty($this->hostname) && in_array($this->pdodriver, array('informix', 'mysql', 'pgsql', 'sybase', 'mssql', 'dblib', 'cubrid'))) + if ( ! empty($this->hostname) + && strpos($this->hostname, ':') === FALSE + && in_array($this->pdodriver, array('informix', 'mysql', 'pgsql', 'sybase', 'mssql', 'dblib', 'cubrid'))) { $this->dsn .= 'host='.$this->hostname.';'; } -- cgit v1.2.3-24-g4f1b From 25dc75595dd3550a6c20f3d34d8f5259465b545f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 13 Feb 2012 14:12:35 -0500 Subject: Re-added if ! empty clause --- system/database/drivers/pdo/pdo_driver.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index c5940ddc8..8516cc6fe 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -121,7 +121,10 @@ class CI_DB_pdo_driver extends CI_DB { // End dsn with a semicolon for extra backward compability // if database property was not empty. - $this->dsn .= rtrim($this->hostname, ';').';'; + if( ! empty($this->database)) + { + $this->dsn .= rtrim($this->hostname, ';').';'; + } } else { -- cgit v1.2.3-24-g4f1b From f4524694418b0203e93c6b0ca1a9f28a9c6e4ba7 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 13 Feb 2012 14:13:28 -0500 Subject: Added missing space --- system/database/drivers/pdo/pdo_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 8516cc6fe..de2b0abeb 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -121,7 +121,7 @@ class CI_DB_pdo_driver extends CI_DB { // End dsn with a semicolon for extra backward compability // if database property was not empty. - if( ! empty($this->database)) + if ( ! empty($this->database)) { $this->dsn .= rtrim($this->hostname, ';').';'; } -- cgit v1.2.3-24-g4f1b