Ensure UTF-8 for MySQL

This commit is contained in:
Savetheinternet 2011-11-05 17:35:07 +11:00
parent b20ba4126a
commit 99979ea41c

View File

@ -44,9 +44,10 @@
$dsn .= ';' . $config['db']['dsn'];
try {
$options = Array(PDO::ATTR_TIMEOUT => $config['db']['timeout']);
$options = Array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
if($config['db']['persistent'])
$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) {
$message = $e->getMessage();