<?php

/**
 * Database Configuration
 *
 * Returns PDO connection parameters read from environment variables.
 * The Database class (INIT-008/INIT-012) reads this file to establish
 * the singleton PDO connection.
 *
 * Architecture rules (ADR-024, DBP v1.0 Ch.4):
 *  - Only parameterized PDO queries. Never concatenate user input into SQL.
 *  - ATTR_EMULATE_PREPARES must be false (real prepared statements).
 *  - ATTR_DEFAULT_FETCH_MODE must be PDO::FETCH_ASSOC.
 *  - All connections use utf8mb4 charset.
 *
 * @package Inveetaire
 * @ref     DBP v1.0 Ch.4, PDD v1.0 Ch.1, ADR-024
 */

return [

    /*
    |--------------------------------------------------------------------------
    | Default Connection Driver
    |--------------------------------------------------------------------------
    | The application targets MariaDB/MySQL at MVP.
    | Schema uses DATETIME (not TIMESTAMP) for PostgreSQL migration readiness.
    */
    'driver' => 'mysql',

    /*
    |--------------------------------------------------------------------------
    | Connection Parameters
    |--------------------------------------------------------------------------
    */
    'host'    => $_ENV['DB_HOST']    ?? '127.0.0.1',
    'port'    => $_ENV['DB_PORT']    ?? '3306',
    'name'    => $_ENV['DB_NAME']    ?? 'inveetaire',
    'user'    => $_ENV['DB_USER']    ?? '',
    'pass'    => $_ENV['DB_PASS']    ?? '',
    'charset' => $_ENV['DB_CHARSET'] ?? 'utf8mb4',

    /*
    |--------------------------------------------------------------------------
    | PDO Options
    |--------------------------------------------------------------------------
    | These are passed directly to the PDO constructor.
    | See Database.php (INIT-012) for usage.
    */
    'options' => [
        PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        PDO::ATTR_EMULATE_PREPARES   => false,
    ],

];
