<?php
    class Database {
        #private $host = "192.168.0.42";
        private $host = "192.168.0.19";
        #private $db_name = "api_db";
        private $username = "hakim";
        private $password = "sap123ok";
        public $conn;

        public function getConnection($db_name) {
            $this->conn = null;

            try {
                #$this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
                $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $db_name, $this->username, $this->password);
                $this->conn->exec("set names utf8");
            } catch(PDOException $exception) {
                echo "Connection error:  ". $exception->getMessage();
            }

            return $this->conn;
        }
    }
?>