database.php: minor format

This commit is contained in:
Zankaria 2024-10-15 19:30:54 +02:00
parent 52759954c8
commit cc82987bb0

View file

@ -70,9 +70,9 @@ function sql_open() {
if (!empty($config['db']['dsn']))
$dsn .= ';' . $config['db']['dsn'];
try {
$options = array(
$options = [
PDO::ATTR_TIMEOUT => $config['db']['timeout'],
);
];
if ($config['db']['type'] == "mysql")
$options[PDO::MYSQL_ATTR_USE_BUFFERED_QUERY] = true;
@ -81,14 +81,12 @@ function sql_open() {
$options[PDO::ATTR_PERSISTENT] = true;
$pdo = new PDO($dsn, $config['db']['user'], $config['db']['password'], $options);
if ($config['debug'])
if ($config['debug']) {
$debug['time']['db_connect'] = '~' . round((microtime(true) - $start) * 1000, 2) . 'ms';
if ($config['db']['type'] == "mysql"){
if (mysql_version() >= 50503)
query('SET NAMES utf8mb4') or error(db_error());
else
if ($config['db']['type'] == "mysql") {
query('SET NAMES utf8') or error(db_error());
}
}
return $pdo;
} catch(PDOException $e) {
$message = $e->getMessage();