init Abgabe

This commit is contained in:
WummerMIB
2025-12-04 23:37:05 +01:00
parent dda70db0be
commit 4db823c14a
534 changed files with 72693 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
class Database {
private static $db = null; // Singleton-Instanz
private $mysqli; // echte DB-Verbindung
// Konstruktor private → kann nur innerhalb der Klasse aufgerufen werden
private function __construct() {
$this->mysqli = new mysqli(
DB_CONNECTION,
DB_USER,
DB_PASS,
DB_DBNAME,
DB_PORT
);
if ($this->mysqli->connect_error) {
die("MySQL Connection Error: " . $this->mysqli->connect_error);
}
}
// Singleton-Zugriff
public static function getInstance() {
if (self::$db === null) {
self::$db = new Database();
}
return self::$db;
}
// Zugriff auf MySQLi
public function getConnection() {
return $this->mysqli;
}
}