Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Designing Interfaces in PHP Introducing Interfaces Implement MySQL RepositoryInterface

Kyle Peterson
Kyle Peterson
Courses Plus Student 2,118 Points

Can't create parameterized query.

The code I have commented out causes a fatal error. However, if I enter the table name directly instead of passing it, the code executes and displays all the information in the posts table. But when I check my work it says its incorrect and leaves an unhelpful hint...

"Bummer: Argument 1 passed to enroll() must be an instance of Student, string given</span></pre>"


class sqlRepository extends PDO implements RepositoryInterface
  public function __construct($dsn)
    try {
      //echo 'it worked';
    } catch (\PDOException $e) {
      echo $e->getMessage();
  public function all($table)
    // $stmt = $this->prepare('SELECT * FROM ?');
    // $stmt->bindValue(1, $table);
    // $stmt->execute();
    $stmt = $this->query("SELECT * FROM posts");
    $results = $stmt->fetchAll(PDO::FETCH_OBJ);
    return $results;