<?php
class Database {

    // Database settings
    private $host = "204.11.58.166";
    private $port = "3306";
    private $db_name = "dms";
    private $username = "user_dms";
    private $password = "M8!q5tV&Glkkiko8";

    public $conn;

    public function getConnection() {

        $this->conn = null;

        try {
            $dsn = "mysql:host={$this->host};port={$this->port};dbname={$this->db_name};charset=utf8mb4";

            $this->conn = new PDO($dsn, $this->username, $this->password);

            // Set error mode
            $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        } catch (PDOException $e) {
            die("Database connection failed: " . $e->getMessage());
        }

        return $this->conn;
    }
}
?>