<?php

require_once __DIR__ . '/config.php';

header('Content-Type: application/json');

try {
    $result = $pdo->query("SELECT 1")->fetchColumn();

    echo json_encode([
        'success' => true,
        'message' => 'BIAPAY database connection is working.',
        'database_test' => $result
    ]);

} catch (Throwable $e) {

    http_response_code(500);

    echo json_encode([
        'success' => false,
        'message' => 'Database test failed.'
    ]);
}