Update database.php

This commit is contained in:
Namhyeon Go 2018-04-29 00:58:22 +09:00 committed by GitHub
parent 34e779ace9
commit bb11f2d9a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ if(!function_exists("get_db_connect")) {
function get_db_connect() {
$config = get_config();
try {
$conn = new PDO(
sprintf(
"mysql:host=%s;dbname=%s;charset=utf8",
@ -21,6 +22,9 @@ if(!function_exists("get_db_connect")) {
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")
);
$conn->query("SET NAMES 'utf8'");
} catch(Exception $e) {
set_error($e->getMessage());
}
return $conn;
}