I have two classes, what is the correct way to call a function from another class, so below error returns
class DB {
public function __construct($user, $password, $database, $host) {
$this->user = $user;
$this->password = $password;
$this->database = $database;
$this->host = $host;
$this->ConectarBanco();
}
protected function ConectarBanco() {
$this->mysqli = new mysqli($this->user, $this->password, $this->database, $this->host);
if (mysqli_connect_errno()) {
die('Não foi possível conectar-se ao banco de dados');
exit();
}
}
public function FecharBanco() {
$this->mysqli->close();
}
public function ExecutarSQL($sql) {
$this->result = $mysqli->query($sql);
return $this->result;
}
public function Consultar($dados) {
$this->newRow = array();
while($row = $mysqli->fetch_array($dados)) {
array_push($this->newRow,$this->row);
}
return $this->newRow;
}
}
class Acao{
public function fnAcao(){
$query = "SELECT * FROM tabela";
$result = DB::ConsultarSQL($query);
return $result;
}
}