forked from leftypol/leftypol
database.php: force utf8mb4 for PDO
This commit is contained in:
parent
e76c4eeed4
commit
c9926802f7
1 changed files with 2 additions and 2 deletions
|
|
@ -66,7 +66,7 @@ function sql_open() {
|
||||||
|
|
||||||
$dsn = $config['db']['type'] . ':' .
|
$dsn = $config['db']['type'] . ':' .
|
||||||
($unix_socket ? 'unix_socket=' . $unix_socket : 'host=' . $config['db']['server']) .
|
($unix_socket ? 'unix_socket=' . $unix_socket : 'host=' . $config['db']['server']) .
|
||||||
';dbname=' . $config['db']['database'];
|
';charset=utf8mb4;dbname=' . $config['db']['database'];
|
||||||
if (!empty($config['db']['dsn']))
|
if (!empty($config['db']['dsn']))
|
||||||
$dsn .= ';' . $config['db']['dsn'];
|
$dsn .= ';' . $config['db']['dsn'];
|
||||||
try {
|
try {
|
||||||
|
|
@ -85,7 +85,7 @@ function sql_open() {
|
||||||
if ($config['debug']) {
|
if ($config['debug']) {
|
||||||
$debug['time']['db_connect'] = '~' . round((microtime(true) - $start) * 1000, 2) . 'ms';
|
$debug['time']['db_connect'] = '~' . round((microtime(true) - $start) * 1000, 2) . 'ms';
|
||||||
if ($config['db']['type'] == "mysql") {
|
if ($config['db']['type'] == "mysql") {
|
||||||
query('SET NAMES utf8') or error(db_error());
|
query('SET NAMES utf8mb4') or error(db_error());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $pdo;
|
return $pdo;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue