<?php

class Conexao{
private $host = "192.168.55.5";
private $db_name = "migracao";
private $username = "gpsi_mv";
private $password = "@UniSL145!#_GPSi@";
private $db_type = "sqlsrv"; //Linux -> dblib || mysql || windows -> sqlsrv
public $conn;


public function getConnection(){

$this->conn = null;

try{
    $this->conn = new PDO($this->db_type .":Server=" . $this->host . ";Database=" . $this->db_name, $this->username, $this->password);
    //$this->conn = new PDO($this->db_type .":Server=" . $this->host, $this->username, $this->password); // sem instanciar o banco
    //$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $this->conn->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_SYSTEM);
    //$this->conn = new PDO($this->db_type .":host=" . $this->host . ";dbname=" . $this->db_name .";charset=latin1", $this->username, $this->password);

    }catch(PDOException $exception){
    echo "Connection error: " . $exception->getMessage();
    }
    
    return $this->conn;
    }
    }
    
?>