Add Docker Compose support und MySQL Datenbank Yipppeeeee

This commit is contained in:
2026-04-23 15:37:50 +02:00
parent cfa72be700
commit 3d3d15e8e5
7 changed files with 120 additions and 1 deletions
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace src;
use PDO;
use PDOException;
class Database
{
private PDO $pdo;
public function __construct(
string $host,
string $port,
string $name,
string $user,
string $password
) {
$dsn = "mysql:host={$host};port={$port};dbname={$name};charset=utf8mb4";
$this->pdo = new PDO($dsn, $user, $password, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
}
public function pdo(): PDO
{
return $this->pdo;
}
}