summaryrefslogtreecommitdiffstats
path: root/system/database/drivers
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-05-19 12:19:43 +0200
committerAndrey Andreev <narf@bofh.bg>2012-05-19 12:19:43 +0200
commitfbd31c8d98bd7e5eac5c8e8c2f102b05350db93e (patch)
treec512a8b8afd8bdc0cef79728e93db8933ea666e2 /system/database/drivers
parent9394f8040ee989e2dfeec42732bc06e52c5ee0c6 (diff)
Fix issue #726
Diffstat (limited to 'system/database/drivers')
-rw-r--r--system/database/drivers/pdo/pdo_driver.php16
1 files changed, 8 insertions, 8 deletions
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 5de2079bb..c38b79c5a 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -51,23 +51,23 @@ class CI_DB_pdo_driver extends CI_DB {
function __construct($params)
{
parent::__construct($params);
-
+
// clause and character used for LIKE escape sequences
if (strpos($this->hostname, 'mysql') !== FALSE)
{
$this->_like_escape_str = '';
$this->_like_escape_chr = '';
-
+
//Prior to this version, the charset can't be set in the dsn
if(is_php('5.3.6'))
{
$this->hostname .= ";charset={$this->char_set}";
}
-
+
//Set the charset with the connection options
$this->options['PDO::MYSQL_ATTR_INIT_COMMAND'] = "SET NAMES {$this->char_set}";
}
- else if (strpos($this->hostname, 'odbc') !== FALSE)
+ elseif (strpos($this->hostname, 'odbc') !== FALSE)
{
$this->_like_escape_str = " {escape '%s'} ";
$this->_like_escape_chr = '!';
@@ -77,9 +77,9 @@ class CI_DB_pdo_driver extends CI_DB {
$this->_like_escape_str = " ESCAPE '%s' ";
$this->_like_escape_chr = '!';
}
-
- $this->hostname .= ";dbname=".$this->database;
-
+
+ empty($this->database) OR $this->hostname .= ';dbname='.$this->database;
+
$this->trans_enabled = FALSE;
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
@@ -94,7 +94,7 @@ class CI_DB_pdo_driver extends CI_DB {
function db_connect()
{
$this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT;
-
+
return new PDO($this->hostname, $this->username, $this->password, $this->options);
}