Files
ctf/cscg25/web/canteenfood/challenge/Database.php
2025-03-24 22:03:34 +01:00

22 lines
479 B
PHP

<?php
class Database {
private static $db;
private $connection;
private function __construct() {
$this->connection = new MySQLi('127.0.0.1', $_SERVER['DB_USER'], $_SERVER['DB_PASS'], $_SERVER['DB_NAME']);
}
function __destruct() {
$this->connection->close();
}
public static function getConnection() {
if (self::$db == null) {
self::$db = new Database();
}
return self::$db->connection;
}
}