Spaces:
Sleeping
Sleeping
File size: 767 Bytes
53658d0 622b7f1 53658d0 56fb0d1 af15846 56fb0d1 d3bf0f8 56fb0d1 53658d0 af15846 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <?php
$host = getenv('DB_HOST') ?: "localhost";
$user = getenv('DB_USER') ?: "root";
$pass = getenv('DB_PASS') ?: "";
$db = getenv('DB_NAME') ?: "kiit_kaffe_db";
try {
$conn = new PDO("mysql:host=$host;dbname=$db;charset=utf8mb4", $user, $pass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
} catch (PDOException $e) {
header("Content-Type: application/json");
$error = [
"status" => "error",
"message" => "Database connection failed",
"details" => $e->getMessage(),
"config" => [
"host" => $host,
"db" => $db,
"user" => $user
]
];
echo json_encode($error);
exit;
}
?>
|