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

Uncaught Error: 'sqlRepository' not found

I am assuming there is a connection already here. I don't see where my error is in the code... is it the question or what am I doing wrong... code attached

sqlRepository.php
<?php
class slqRepository extends PDO implements RepositoryInterface
{
  public function all($table) {
        // Prepare Query
        $pdoS = $this->prepare('SELECT * FROM ?', [$table]);
        // Execute Query
        $pdoS->execute();
        // Return feteched table
        return $pdoS->fetchAll(PDO::FETCH_OBJ);
    }
}

1 Answer

I figured it out by reading another discussion --- How to use PDO inside of child of PDO?

Must use query() and not do a prepared statement.