<?php
$config = require __DIR__ . '/config.php';
$db = $config['db'];

$dsn = "mysql:host={$db['host']};port={$db['port']};dbname={$db['name']};charset=utf8mb4";

$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, $db['user'], $db['pass'], $options);
} catch (PDOException $e) {
  die("DB connection failed: " . $e->getMessage());
}
// try {
//   $pdo = new PDO($dsn, $db['user'], $db['pass'], $options);
//   echo "✅ DB connected<br>";
// } catch (PDOException $e) {
//   die("❌ DB connection failed: " . $e->getMessage());
// }
