<?php

declare(strict_types=1);

// Database configuration
const DB_HOST = 'localhost';
const DB_NAME = 'uniquedigitals_stcalevel';
const DB_USER = 'uniquedigitals_stcalevel';
const DB_PASS = 'uniquedigitals_stcalevel';

try {
    $pdo = new PDO(
        dsn: "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=utf8mb4",
        username: DB_USER,
        password: DB_PASS,
        options: [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            PDO::ATTR_EMULATE_PREPARES => false,
        ]
    );

    // Optional: Test the connection
    $pdo->query('SELECT 1');

} catch (PDOException $e) {
    error_log("Database connection failed: " . $e->getMessage());
    die("Database connection error. Please try again later.");
}

// Keep mysqli connection for backward compatibility if needed
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);

if (!$conn) {
    error_log("MySQLi connection failed: " . mysqli_connect_error());
    die("Database connection error. Please try again later.");
}

?>
