Colleagues, I have a connection class:
class Conecta
{
private $Servidor = '127.0.0.1';
private $Usuario = 'root';
private $Senha = 'senha';
private $Banco = 'banco';
// Protegido
protected $Conecta;
// Faz a conexão
public function conectar(){
$this->Conecta = mysqli_connect($this->Servidor,$this->Usuario,$this->Senha,$this->Banco);
}
And I have a class of methods:
class Metodos extends Conecta
{
// Primeiro método
public functionPrimeiro(){
$conectar = new Conecta();
$conectar->conectar();
$sql = mysqli_query($conectar->conectar(), "MINHA QUERY");
}
// Segundo método
public functionSegunda(){
$conectar = new Conecta();
$conectar->conectar();
$sql = mysqli_query($conectar->conectar(), "MINHA QUERY");
}
}
Note that within each method I use:
$conectar = new Conecta();
$conectar->conectar();
Would there be any way I could not use within each method, or could it just be that way?