<?php
declare(strict_types=1);

/**
 * config/db.php
 *
 * - Choose ONE driver below (others stay commented).
 * - Each driver has its own config section.
 * - The file returns ONE normalized array used by Database::createPdo().
 */

// ------------------------------------------------------------
// 1) Driver selection (choose one)
// ------------------------------------------------------------
//$driver = 'pqsql';
$driver = 'mysql';
// $driver = 'sqlite';

// ------------------------------------------------------------
// 2) Driver-specific configuration sections
// ------------------------------------------------------------

// ---- PostgreSQL (PDO driver: pgsql) -------------------------
$pgsql = [
    'driver'   => 'pgsql',
    'host'     => 'localhost',
    'port'     => 5432,
    'dbname'   => 'mydb',

    // optional: schema/search_path (commonly "public")
    'schema'   => 'public',

    'user'     => 'myuser',
    'password' => 'secret',

    'options'  => [
        PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    ],
];

// ---- MySQL / MariaDB (PDO driver: mysql) -------------------
$mysql = [
    'driver'   => 'mysql',
    'host'     => 'localhost',
    'port'     => 3306,
    'dbname'   => 'd0453540',
    'charset'  => 'utf8mb4',

    // Alternative to host/port:
    // 'unix_socket' => '/var/run/mysqld/mysqld.sock',

    'user'     => 'd0453540',
    'password' => 'P6jGRrSaX8QSiBMEJBL7',

    'options'  => [
        PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        PDO::ATTR_EMULATE_PREPARES   => false,
    ],
];

// ---- SQLite (PDO driver: sqlite) ---------------------------
$sqlite = [
    'driver'   => 'sqlite',

    // Use an absolute path in production, e.g. /var/app/data/app.sqlite
    // For demo/dev you can use a relative path.
    'path'     => __DIR__ . '/../var/app.sqlite',

    // SQLite ignores host/port/user/pass
    'options'  => [
        PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    ],
];

// ------------------------------------------------------------
// 3) Select and return config
// ------------------------------------------------------------
switch ($driver) {
    case 'pgsql':
        return $pgsql;

    case 'mysql':
        return $mysql;

    case 'sqlite':
        return $sqlite;

    default:
        throw new RuntimeException('Unsupported DB driver in config/db.php: ' . $driver);
}
