浏览代码

Include `set names` for MySQL

Ensure that MySQL connections are in the desired encoding.

Refs #6332
Mark Story 11 年之前
父节点
当前提交
20bec081d3
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      src/Database/Driver/Mysql.php

+ 3 - 0
src/Database/Driver/Mysql.php

@@ -62,6 +62,9 @@ class Mysql extends \Cake\Database\Driver
         if (!empty($config['timezone'])) {
         if (!empty($config['timezone'])) {
             $config['init'][] = sprintf("SET time_zone = '%s'", $config['timezone']);
             $config['init'][] = sprintf("SET time_zone = '%s'", $config['timezone']);
         }
         }
+        if (!empty($config['encoding'])) {
+            $config['init'][] = sprintf("SET NAMES %s", $config['encoding']);
+        }
 
 
         $config['flags'] += [
         $config['flags'] += [
             PDO::ATTR_PERSISTENT => $config['persistent'],
             PDO::ATTR_PERSISTENT => $config['persistent'],