1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-01-31 04:13:49 +01:00

Ensure UTF-8 for MySQL

This commit is contained in:
Savetheinternet 2011-11-05 17:35:07 +11:00
parent f709da225b
commit 0f2792938a

View File

@ -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();