diff --git a/backend/app/Core/Database.php b/backend/app/Core/Database.php index 06d24ff..5190e61 100644 --- a/backend/app/Core/Database.php +++ b/backend/app/Core/Database.php @@ -13,18 +13,23 @@ class Database private static ?PDO $instance = null; /** - * Get active PDO database instance + * Get active PDO database instance (alias or direct connection) * * @return PDO * @throws PDOException */ + public static function getInstance(): PDO + { + return self::getConnection(); + } + public static function getConnection(): PDO { if (self::$instance === null) { $host = getenv('DB_HOST') ?: '127.0.0.1'; $port = getenv('DB_PORT') ?: '3306'; - $dbName = getenv('DB_DATABASE') ?: 'nabeh_master'; - $username = getenv('DB_USERNAME') ?: 'root'; + $dbName = getenv('DB_DATABASE') ?: 'saqelDB'; + $username = getenv('DB_USERNAME') ?: 'saqelUser'; $password = getenv('DB_PASSWORD') ?: ''; $dsn = "mysql:host={$host};port={$port};dbname={$dbName};charset=utf8mb4"; diff --git a/backend/public/migrate.php b/backend/public/migrate.php index af09c45..13a1fad 100644 --- a/backend/public/migrate.php +++ b/backend/public/migrate.php @@ -7,7 +7,7 @@ use App\Core\Database; header('Content-Type: application/json; charset=utf-8'); try { - $db = Database::getInstance()->getConnection(); + $db = Database::getConnection(); // Disable Foreign Key checks explicitly on the active connection $db->exec("SET FOREIGN_KEY_CHECKS = 0;");