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're experiencing this error: Fatal error: Call a member function execute () on a non-object in
Does anyone know why the first mode does not work?