I was trying to run a simple query through sqlsrv_query. I have a class which connect to the database:
class ConexionDB
{
private $server = SERVIDOR;
private $user = USUARIO;
private $passw = PASSW;
private $db_name = DB_NAME;
private $conn;
private $error;
private $stmt;
function __construct()
{
try {
$this->conn = sqlsrv_connect($this->server,
array(
"Database" => $this->db_name,
"UID" => $this->user,
"PWD" => $this->passw
)
);
} catch (Exception $e) {
throw $e;
}
}
function query($query)
{
$this->stmt = sqlsrv_query($this->conn, $query);
}
}
And I have a DAO class which make the query like this:
$database = new ConexionDB();
$sql = " SELECT *
FROM SistemaWeb.dbo.Empresa ";
$database->query($sql);
But the result gives me this error:
sqlsrv_query() expects parameter 1 to be resource, boolean given
What could be wrong? Thanks for replies.
Edit: Here is the result of the query through SQL Management: