<?php
// api/db.php - JSON Safe Database Connection (伏羲防護版 V4)

$host = 'localhost'; 
$dbname = 'flowzoocom_mflowzoo'; // 🐘 破案關鍵：更新為正確的資料庫名稱
$user = 'flowzoocom_admin';     // 🐘 如果您的「使用者名稱」也是 flowzoocom_flowzoo，請將這裡同步修改
$pass = 'j%d?2PW;7X-0C,lE';
$charset = 'utf8mb4';

$dsn = "mysql:host=$host;dbname=$dbname;charset=$charset";
$options = [
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_EMULATE_PREPARES   => false,
];

try {
    $pdo = new PDO($dsn, $user, $pass, $options);
} catch (\PDOException $e) {
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode([
        "success" => false, 
        "message" => "資料庫連線被阻擋 (db.php): 請檢查帳號密碼或 Host 設定。詳細錯誤：" . $e->getMessage()
    ]);
    exit;
}
?>