database.php: force utf8mb4 for PDO

This commit is contained in:
Zankaria 2025-06-01 16:05:15 +02:00
parent e76c4eeed4
commit c9926802f7

View file

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