Browse Source

Include `set names` for MySQL

Ensure that MySQL connections are in the desired encoding.

Refs #6332
Mark Story 11 years ago
parent
commit
20bec081d3
1 changed files with 3 additions and 0 deletions
  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'])) {
             $config['init'][] = sprintf("SET time_zone = '%s'", $config['timezone']);
         }
+        if (!empty($config['encoding'])) {
+            $config['init'][] = sprintf("SET NAMES %s", $config['encoding']);
+        }
 
         $config['flags'] += [
             PDO::ATTR_PERSISTENT => $config['persistent'],