This commit is contained in:
2026-01-23 23:45:16 +01:00
parent 0a784ef454
commit ed5d77bf6c
4 changed files with 23 additions and 10 deletions

12
tools/db.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
function tools_build_pdo(): PDO
{
$cfg = require __DIR__ . '/../src/config.php';
$dsn = "mysql:host={$cfg['db_host']};dbname={$cfg['db_name']};charset={$cfg['db_charset']}";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
];
return new PDO($dsn, $cfg['db_user'], $cfg['db_pass'], $options);
}