PHP Designing Interfaces in PHP Introducing Interfaces Implement MySQL RepositoryInterface

problem with prepare statement PDO

In function find, although I used prepare statement, when I click button "Recheck work", the app still announce an error: "make sure you use prepared statement". I truly don't understand how. Please help me


class sqlRepository extends PDO implements RepositoryInterface{
  protected $db;

  public function __construct($file){
      $this->db = new PDO("sqlite:" . __DIR__ . "/database.db");
      $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    }catch (Exception $e){
      echo "Unable to connect";

  public function all($tableName){
    try {
      $results = $this->db->query("SELECT * FROM $tableName");
      return $results->fetchAll(PDO::FETCH_OBJ);
    } catch (Exception $e) {
      echo "Unable to retrieved results";

  public function find($entity, $value, $field = 'id'){
    $statement = $this->db->preapre("SELECT * FROM :entity WHERE :field = :value");
    $statement->bindParam(':entity', $entity, PDO::PARAM_STR);
    $statement->bindParam(':field', $field, PDO::PARAM_STR);
    $statement->bindParam(':value', $value, PDO::PARAM_STR);
    return $statement->fetchAll(PDO::FETCH_OBJ);


1 Answer

Sorry all, I found my problem: I typed wrong word "prepare". I also follow the question to solve my problem Thanks all :)