diff options
author | Derek Jones <derek.jones@ellislab.com> | 2011-04-20 02:47:34 +0200 |
---|---|---|
committer | Derek Jones <derek.jones@ellislab.com> | 2011-04-20 02:47:34 +0200 |
commit | bab1a6aab7aa9bd2ba0ad7bc51973dd00d273b31 (patch) | |
tree | a2360c3d03813783d0fca44b1fe2947e9873fb26 /system/database/drivers/mysql | |
parent | f5c840241084e03d49e521bfcb62d2adbe9fce7d (diff) | |
parent | 6ae70cc8499499b5d77d77ec8974f95873edb861 (diff) |
Automated merge with http://hg.ellislab.com/CodeIgniter-Reactor
Diffstat (limited to 'system/database/drivers/mysql')
-rw-r--r-- | system/database/drivers/mysql/mysql_driver.php | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 4ff9b0a11..b7d547cc0 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -132,7 +132,22 @@ class CI_DB_mysql_driver extends CI_DB { */ function db_set_charset($charset, $collation) { - return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id); + static $use_set_names; + + if ( ! isset($use_set_names)) + { + // mysql_set_charset() requires PHP >= 5.2.3 and MySQL >= 5.0.7, use SET NAMES as fallback + $use_set_names = (version_compare(PHP_VERSION, '5.2.3', '>=') && version_compare(mysql_get_server_info(), '5.0.7', '>=')) ? FALSE : TRUE; + } + + if ($use_set_names) + { + return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id); + } + else + { + return @mysql_set_charset($charset, $this->conn_id); + } } // -------------------------------------------------------------------- |