<?php
// used to get mysql database connection
//echo "Connection start: ";
class DatabaseService{

    private $db_host = "localhost";
    private $db_name = "rsipur";
    private $db_user = "hosmis1";
    private $db_password = "";
    private $connection;
//private $options  = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,);
    public function getConnection(){

        $this->connection = null;

        try{
            $this->connection = new PDO("mysql:host=" . $this->db_host . ";port=3306;dbname=" . $this->db_name, $this->db_user, $this->db_password);
			//$this->connection = new PDO("sqlsrv:Server=hosmis01;Database=rsgubug", "sa", "pkugubug_2015");
			//$dsn = "sqlsrv:Server=hosmis01;Database=rsgubug";
//$this->connection = new PDO($dsn, "sa", "pkugubug_2015",$options);
//$this->con = new PDO($this->server, $this->user,$this->pass,$this->options);
//          return $this->con;
//$this->connection->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

			//echo "Connection ok: ";
        }catch(PDOException $exception){
			//echo "Connection tes: ";
            echo "Connection failed: " . $exception->getMessage();
        }

        return $this->connection;
    }
}
?>