<?php
// db.php

// ✅ PHP timezone (Uzbekistan / Tashkent)
date_default_timezone_set('Asia/Tashkent');

$DB_HOST = 'localhost';
$DB_NAME = 'dailslie_mark2';
$DB_USER = 'dailslie_mark2';
$DB_PASS = 'Sodiq1613181';

try {
    $pdo = new PDO(
        "mysql:host={$DB_HOST};dbname={$DB_NAME};charset=utf8mb4",
        $DB_USER,
        $DB_PASS,
        [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            // Muhim: real prepared statements (xohlasang true ham qilsa bo‘ladi)
            PDO::ATTR_EMULATE_PREPARES   => false,
        ]
    );

    // ✅ MySQL sessiya timezone'ni Toshkent (GMT+5) qilib qo'yamiz
    // Bu faqat shu PDO connection uchun ishlaydi
    $pdo->exec("SET time_zone = '+05:00'");

    // ixtiyoriy: formatlar bilan muammo bo‘lmasin
    $pdo->exec("SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci");

} catch (PDOException $e) {
    die("DB connection error: " . $e->getMessage());
}
