I was reader about PDO , and I was wondering what is the deference between those two methods:
public function query($sql)
{
$req = $this->db->prepare($sql);
$req->execute();
return $req->fetchAll(PDO::FETCH_OBJ);
}
public function query($sql, $data = array())
{
$req = $this->db->prepare($sql);
$req->execute($data);
return $req->fetchAll(PDO::FETCH_OBJ);
}
In the second method, execute has an empty array as a parameter and the first one doesn't, what is the role of using an empty array as a parameter for execute ?