I searched in many places and was amazed to find almost nothing of PHP OO using SQL Server. In short, I can not understand what is wrong here, I think it helps, thank you in advance.
<?php
class Conexao{
private $Localhost = 'NOTEBOOK101010\SQLEXPRESS';
private $User = 'sa';
private $Pass = '';
private $Database = 'ALISON';
private $Con = null;
private $Coninfo = null;
function __construct() {
$this->Coninfo;
}
public function Conectar(){
$this->Localhost;
$this->User;
$this->Pass;
$this->Database;
$this->Con = array("Database" => $this->Localhost, "UID" => $this->User, "PWD" => $this->Pass);
$this->Coninfo = sqlsrv_connect($this->Con, $this->Database);
if($this->Coninfo){
echo "Conectou";
return true;
}else{
die(print_r(sqlsrv_error(), true));
}
}
}
?>
This is my class Connection below my class Admin
<?php
include_once 'Conexao.class.php';
class Administrador {
private $Nome;
private $Endereco;
private $Telefone;
private $Con;
public function __construct() {
$this->Con = new Conexao();
}
public function inserir($Nome, $Endereco, $Telefone){
$sql = "INSERT INTO CADPES (NOME, ENDERECO, NUMERO)VALUES($this->Nome, $this->Endereco, $this->Telefone)";
$query = sqlsrv_query($this->Con->Conectar(), $sql);
}
}
I wonder where I'm going wrong!