<?php
// 数据库配置
if (!defined('DB_HOST'))   define('DB_HOST', 'localhost');
if (!defined('DB_PORT'))  define('DB_PORT', '3306');
if (!defined('DB_USER'))  define('DB_USER', 'cms_user');
if (!defined('DB_PASS'))  define('DB_PASS', 'Cms@2026db');
if (!defined('DB_NAME'))  define('DB_NAME', 'cms_db');

try {
    $pdo = new PDO(
        'mysql:host=' . DB_HOST . ';port=' . DB_PORT . ';dbname=' . DB_NAME . ';charset=utf8mb4',
        DB_USER, DB_PASS,
        [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC]
    );
    $GLOBALS['pdo'] = $pdo;
    $GLOBALS['db'] = $pdo;
} catch (PDOException $e) { die('Database connection failed: ' . $e->getMessage()); }
