I'm trying to make a simple project using PDO. I have a class UserDAO with two SELECT functions:
public function getAll(){
 $query="select * from users";
 $res = $this->db->query($query);
 return $res;
}
...and this one...
public function getAllWhere($where){
 $query="select * from users where ?";
 $res = $this->db->query($query,array($where));
 return $res; 
}
When I call the function getAll(), it works fine:
<?php
 $ud = new UserDAO();
 $result=$ud->getAll();
 foreach ($result as $row){
   echo '<br/>'.$row['id'].' '.$row['username'];
}
?>
But when I try to user the other function...
<?php
 $ud = new UserDAO();
 $result=$ud->getAllWhere('id>10');
 foreach ($result as $row){
   echo '<br/>'.$row['id'].' '.$row['username'];
}
?>
...it doesn't work. The error is:
PDOStatement::execute() expects parameter 1 to be array, string given
How can I pass the whole WHERE condition as a parameter? I would also like to make another step forward and to insert the table name ("users") as a parameter too.
Thanks.
