I'm attempting to create a somewhat simple database abstraction layer. All seemed to be going well until I tried to test it with a query which it will not work with. Looking for a little help on this one.
Errors:
( ! ) Notice: Undefined variable: dbh in C:\wamp64\www\phpwebsite\db.php on line 29
( ! ) Fatal error: Call to a member function query() on null in C:\wamp64\www\phpwebsite\db.php on line 29
DB Class:
include_once 'IAbstractDatabase.php';
class db implements IAbstractDatabase
{
public function __construct()
{
    $username = "root";
    $pass = "";
    try {   
        $dbh = new PDO("mysql:host=localhost;dbname=imperialcars", $username, $pass);
    } catch (PDOException $e) {
        echo $e->getMessage()."</br>";
        die();
    }
}
public function __destruct()
{
    $dbh=null;
}
public function select($query)
{
    return $stmt = $dbh->query($query);
}
public function query($query)
{
    return $stmt = $dbh->query($query);
}
}
$dbh = new db();
$dbh->query("INSERT INTO users (userid, username, userfname, userlname, email, password, banned, admin) VALUES (NULL, 'user2', 'john', 'doe', 'johndoe@hotmail.com', 'password', '0', '0')");
Appreciate your help and feedback.
