<?php
class Database
{
    protected $connect;  // Change to protected so subclasses can access it
    private $host = "localhost";
    private $user = "robotis2_user";
    private $db = "robotis2_bajaliainternetseba";
    private $pass = "robotis2_user";

    public function __construct()
    {
        try {
            $this->connect = new PDO(
                "mysql:host=" . $this->host . ";dbname=" . $this->db . ";charset=utf8mb4", // charset added
                $this->user,
                $this->pass
            );

            // Error mode set to exception
            $this->connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        } catch (PDOException $e) {
            echo "Connection failed: " . $e->getMessage();
        }
    }


    // Method to get the connection
    public function getConnection()
    {
        return $this->connect;
    }
}
