0
public function select($sql, $array = array())
{
$sth = $this->conn->prepare($sql);
if(!empty($array)){
foreach ($array as $key => $value) {
$sth->bindValue(":".$key, $value);
}
}
$this->stmt = $sth;
}
public function execute(){
if($this->stmt->execute()){
return $this->stmt;
} else {
return false;
}
}
$database = new DataBase();
//1º : Assim não funciona:
$database->select(
"SELECT * FROM tabela WHERE id=:id",
array("id" => 1)
)->execute();
//2º : Assim funciona:
//$stmt = $database->execute();
You are showing this error: Fatal error: Call to a Member Function execute() on a non-object in
Does anyone know why the first mode does not work?