diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-02-14 10:32:18 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-02-14 10:32:18 +0100 |
commit | d9c592b04f129fa01b72e3a0953fd48e85c18f2d (patch) | |
tree | 28004d93d998865c575f69df5c3e78f726038ef5 /system/database/drivers/pdo/pdo_driver.php | |
parent | c7ca1a66c43f7a17f477316c07cf29c7b2526753 (diff) | |
parent | e35d6943d513b4f016b763eebe8b97a9f1c902e3 (diff) |
Merge remote-tracking branch 'upstream/develop' into develop-issue-128
Diffstat (limited to 'system/database/drivers/pdo/pdo_driver.php')
-rw-r--r-- | system/database/drivers/pdo/pdo_driver.php | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index fc378daeb..de2b0abeb 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -116,8 +116,15 @@ 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 = substr($this->hostname, 0, strpos($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->hostname, ';').';'; + } } else { @@ -132,7 +139,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.';'; } |