Ensure UTF-8 for MySQL
This commit is contained in:
parent
b20ba4126a
commit
99979ea41c
@ -44,9 +44,10 @@
|
|||||||
$dsn .= ';' . $config['db']['dsn'];
|
$dsn .= ';' . $config['db']['dsn'];
|
||||||
try {
|
try {
|
||||||
$options = Array(PDO::ATTR_TIMEOUT => $config['db']['timeout']);
|
$options = Array(PDO::ATTR_TIMEOUT => $config['db']['timeout']);
|
||||||
|
$options = Array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
|
||||||
if($config['db']['persistent'])
|
if($config['db']['persistent'])
|
||||||
$options[PDO::ATTR_PERSISTENT] = true;
|
$options[PDO::ATTR_PERSISTENT] = true;
|
||||||
return $pdo = new PDO($dsn, $config['db']['user'], $config['db']['password']);
|
return $pdo = new PDO($dsn, $config['db']['user'], $config['db']['password'], $options);
|
||||||
} catch(PDOException $e) {
|
} catch(PDOException $e) {
|
||||||
$message = $e->getMessage();
|
$message = $e->getMessage();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user