asd
This commit is contained in:
12
tools/db.php
Normal file
12
tools/db.php
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user