<?php

$env = parse_ini_file(__DIR__ . '/../.env');

if ($env === false) { die('Impossible de charger le fichier .env'); }

try {
    $dsn = sprintf('mysql:host=%s;port=%s;dbname=%s;charset=%s', $env['DB_HOST'], $env['DB_PORT'], $env['DB_NAME'], $env['DB_CHARSET']);
    $bdd = new PDO( $dsn, $env['DB_USER'], $env['DB_PASS'],
        [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            PDO::ATTR_EMULATE_PREPARES => false,
        ]
    ); 
} catch (PDOException $e) { die('Erreur : ' . $e->getMessage()); }