summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/pdo/pdo_driver.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/database/drivers/pdo/pdo_driver.php')
-rw-r--r--system/database/drivers/pdo/pdo_driver.php36
1 files changed, 25 insertions, 11 deletions
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 10ef00c49..4f4f44ba7 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -18,7 +18,7 @@
*
* @package CodeIgniter
* @author EllisLab Dev Team
- * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* @link http://codeigniter.com
* @since Version 2.1.0
@@ -57,7 +57,8 @@ class CI_DB_pdo_driver extends CI_DB {
*/
var $_count_string = "SELECT COUNT(*) AS ";
var $_random_keyword;
-
+
+ var $options = array();
function __construct($params)
{
@@ -68,6 +69,15 @@ class CI_DB_pdo_driver extends CI_DB {
{
$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)
{
@@ -80,7 +90,11 @@ class CI_DB_pdo_driver extends CI_DB {
$this->_like_escape_chr = '!';
}
- $this->hostname = $this->hostname . ";dbname=".$this->database;
+ if (strpos($this->hostname, 'sqlite') === FALSE)
+ {
+ $this->hostname .= ";dbname=".$this->database;
+ }
+
$this->trans_enabled = FALSE;
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
@@ -94,9 +108,9 @@ class CI_DB_pdo_driver extends CI_DB {
*/
function db_connect()
{
- return new PDO($this->hostname,$this->username,$this->password, array(
- PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT
- ));
+ $this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT;
+
+ return new PDO($this->hostname, $this->username, $this->password, $this->options);
}
// --------------------------------------------------------------------
@@ -109,10 +123,10 @@ class CI_DB_pdo_driver extends CI_DB {
*/
function db_pconnect()
{
- return new PDO($this->hostname,$this->username,$this->password, array(
- PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT,
- PDO::ATTR_PERSISTENT => true
- ));
+ $this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT;
+ $this->options['PDO::ATTR_PERSISTENT'] = TRUE;
+
+ return new PDO($this->hostname, $this->username, $this->password, $this->options);
}
// --------------------------------------------------------------------
@@ -244,7 +258,7 @@ class CI_DB_pdo_driver extends CI_DB {
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
- $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
+ $this->_trans_failure = (bool) ($test_mode === TRUE);
return $this->conn_id->beginTransaction();
}