I have a few classes that perform some MySQL queries and prepared statements. However, I am lost in how to incorporate my PDO object within those classes. For example, I want to do something like this:
<?php
$dbh = new PDO(...);
class Foo extends PDO {
public $dbh;
public function bar() {
$this->dbh->prepare('SELECT * FROM table');
$this->dbh->execute();
}
}
?>
Unfortunately, it doesn't work. Can anyone suggest an elegant way to do this? Thanks for your time. Sorry I'm new to this, please leave any comments if you are unclear about anything and I'll do my best to respond!