<?php
class Database {
    private $host = "localhost";
    private $db_name = "prodi970_chamada";
    private $username = "prodi970_chamada";
    private $password = "@$6Zok_q@lZl";
    private static $conn = null;

    public function getConnection() {
        if (self::$conn === null) {
            try {
                self::$conn = new PDO(
                    "mysql:host=" . $this->host . ";dbname=" . $this->db_name,
                    $this->username,
                    $this->password,
                    [
                        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
                        PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8; SET time_zone = '-03:00';"
                    ]
                );
            } catch(PDOException $e) {
                error_log("Erro de conex«Șo: " . $e->getMessage());
                throw new Exception("Erro de conex«Șo com o banco de dados");
            }
        }
        return self::$conn;
    }
}
?> 