<?php

// config/database.php

date_default_timezone_set('Africa/Lagos');

define('DB_HOST', 'localhost');
define('DB_NAME', 'pecyrevi_trading_tool');
define('DB_USER', 'pecyrevi_pecsysta');
define('DB_PASS', 'yhgmjAZ$[kIGUomp');

function db()
{
    static $pdo = null;

    if ($pdo === null) {
        try {
            $pdo = new PDO(
                "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=utf8mb4",
                DB_USER,
                DB_PASS,
                [
                    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
                ]
            );
        } catch (PDOException $e) {
            die("Database connection failed: " . $e->getMessage());
        }
    }

    return $pdo;
}

define('TWELVEDATA_API_KEY', '7a13fd145e684c4082bc2557e3ee2064');