<?php 

Class User{

    public function connectDB(){
        date_default_timezone_set('Asia/Dushanbe');
        $con = sqlsrv_connect('127.0.0.1', array('Database' => 'TBO','UID' => '', 'PWD' => '',"CharacterSet" => "UTF-8")) or die(print_r(sqlsrv_errors()));   
        return $con;
    }



    public function auth($login,$pass){
        $con = $this->connectDB();
        $sql = "Select * from Users Where Login = '".$login."' and Password = '".$pass."' ";
        $query = sqlsrv_query($con,$sql) or die("User_auth".print_r(sqlsrv_errors()));
        if(sqlsrv_has_rows($query)){
            $row = sqlsrv_fetch_array($query);
            $arr = $row;
        }
        else{
            $arr = ["code"=>100];
        }
        return $arr;
    }

}
?>