From 7d834be1501dcc3dc85af546f973f27fefcbd0f4 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 26 Oct 2011 11:26:17 -0400 Subject: Set charset in DSN if PHP >= 5.3.6 --- system/database/drivers/pdo/pdo_driver.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'system/database') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 0c41bfffe..b727b8098 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -70,6 +70,12 @@ 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}"; } -- cgit v1.2.3-24-g4f1b