<?php
// config.php

$host = 'localhost';
$db   = 'ba_appliances';
$user = 'root'; // Update this if your local environment uses a different username
$pass = '';     // Update this if your local environment requires a password
$charset = 'utf8mb4';

$dsn = "mysql:host=$host;dbname=$db;charset=$charset";

// Set options for robust error handling and secure fetching
$options = [
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_EMULATE_PREPARES   => false,
];

try {
    // Establish the connection
    $pdo = new PDO($dsn, $user, $pass, $options);
} catch (\PDOException $e) {
    // Halt execution and show error if the connection fails
    // Note: On a live server, you'd log this instead of showing it to the user
    die("Database connection failed: " . $e->getMessage());
}
?>