summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/pdo/pdo_driver.php
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2012-02-13 20:46:00 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2012-02-13 20:46:00 +0100
commit534e0a5d91247d8d3a35c3da41dee230f9c8a458 (patch)
tree6a76f47f47ebcbba07717fd977ff6133ddeae70e /system/database/drivers/pdo/pdo_driver.php
parenta879147d8e117d4a87aeab79eb0347fb7ae13c76 (diff)
parentf4524694418b0203e93c6b0ca1a9f28a9c6e4ba7 (diff)
Merge pull request #1037 from timw4mail/develop
Refixed Old-style pdo connection string
Diffstat (limited to 'system/database/drivers/pdo/pdo_driver.php')
-rw-r--r--system/database/drivers/pdo/pdo_driver.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 5991586c7..de2b0abeb 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -116,14 +116,14 @@ 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 +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.';';
}