abschluss

This commit is contained in:
2025-06-20 07:55:37 +00:00
parent 497e6a0bdf
commit 6c2e71dd53
34 changed files with 1370 additions and 382 deletions

View File

@ -4,9 +4,21 @@ namespace Blog\Database;
use PDO;
use PDOException;
/**
* Verwaltet die Verbindung zur MySQL-Datenbank.
*/
class Database {
/**
* @var PDO|null Statische Instanz der Datenbankverbindung.
*/
private static ?PDO $pdo = null;
/**
* Stellt eine Verbindung zur Datenbank her oder gibt die bestehende zurück.
*
* @return PDO Die aktive PDO-Verbindung.
* @throws PDOException Falls die Verbindung fehlschlägt.
*/
public static function getConnection(): PDO {
if(self::$pdo === null) {
$config = parse_ini_file(__DIR__ . "/../../.env");