summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/mysql/mysql_driver.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2015-12-14 16:56:14 +0100
committerAndrey Andreev <narf@devilix.net>2015-12-14 16:56:14 +0100
commit85bc9fc53e4c3e46b2f4e1b1eac7e2828d4869e6 (patch)
tree78abe651f52c39be43a3e22ba38c1e83160a7bc8 /system/database/drivers/mysql/mysql_driver.php
parent788fb4aa823179e7c4401f5384207d916697bb7e (diff)
Change DB charset handling
Close #4311
Diffstat (limited to 'system/database/drivers/mysql/mysql_driver.php')
-rw-r--r--system/database/drivers/mysql/mysql_driver.php31
1 files changed, 15 insertions, 16 deletions
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 9c630d0d6..76f50368f 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -147,12 +147,24 @@ class CI_DB_mysql_driver extends CI_DB {
: FALSE;
}
- if ($this->stricton && is_resource($this->conn_id))
+ if (is_resource($this->conn_id))
{
- $this->simple_query('SET SESSION sql_mode="STRICT_ALL_TABLES"');
+ if ( ! mysql_set_charset($this->char_set, $this->conn_id))
+ {
+ log_message('error', "Database: Unable to set the configured connection charset ('{$this->char_set}').");
+ $this->close();
+ return ($this->db->debug) ? $this->display_error('db_unable_to_set_charset', $charset) : FALSE;
+ }
+
+ if ($this->stricton)
+ {
+ $this->simple_query('SET SESSION sql_mode="STRICT_ALL_TABLES"');
+ }
+
+ return $this->conn_id;
}
- return $this->conn_id;
+ return FALSE;
}
// --------------------------------------------------------------------
@@ -200,19 +212,6 @@ class CI_DB_mysql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @param string $charset
- * @return bool
- */
- protected function _db_set_charset($charset)
- {
- return mysql_set_charset($charset, $this->conn_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Database version number
*
* @return string