<?php
// app/config/database.php  (MySQLi)

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

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

try {
  $conn = new mysqli($db['host'], $db['user'], $db['pass'], $db['name']);
  $conn->set_charset($db['charset'] ?? 'utf8mb4');
} catch (Exception $e) {
  http_response_code(500);
  die("Database connection failed. Check app/config/config.php");
}

return $conn;
