Charakterverwalter (westreiche_website) ergänzen, Website-Nav "Charaktere"
This commit is contained in:
parent
d107f90c93
commit
01dae01c7c
84 changed files with 8915 additions and 17 deletions
33
westreiche_website/app/db.php
Normal file
33
westreiche_website/app/db.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/** Westreiche – Datenbankverbindung (PDO, MariaDB/MySQL). */
|
||||
|
||||
function db(): PDO
|
||||
{
|
||||
static $pdo = null;
|
||||
if ($pdo instanceof PDO) {
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
$db = (array) config('db', []);
|
||||
$dsn = sprintf(
|
||||
'mysql:host=%s;port=%d;dbname=%s;charset=%s',
|
||||
(string) ($db['host'] ?? 'localhost'),
|
||||
(int) ($db['port'] ?? 3306),
|
||||
(string) ($db['name'] ?? ''),
|
||||
(string) ($db['charset'] ?? 'utf8mb4')
|
||||
);
|
||||
|
||||
$pdo = new PDO($dsn, (string) ($db['user'] ?? ''), (string) ($db['password'] ?? ''), [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
PDO::ATTR_STRINGIFY_FETCHES => false,
|
||||
]);
|
||||
$pdo->exec("SET time_zone = '+00:00'");
|
||||
if (function_exists('ws_migrations_apply')) {
|
||||
ws_migrations_apply($pdo);
|
||||
}
|
||||
return $pdo;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue