Hello Im getting this error
Call to a member function query() on null
Fatal error: Call to a member function query() on null
Call to member function query() on Null
But neither seems to solve my problem
I have db class
class DB
{
private $link;
public function __construct()
{
$this->link = new mysqli(HOSTNAME, USERNAME, PASSWORD, DBNAME);
if ($this->link->connect_error)
{
exit('Some of the database login credentials seem to be wrong.' . $this->link->connect_error);
}
}
}
Then I attempt to query the database with this class
class UserModel extends DB
{
private $db;
public function __construct()
{
$this->getUser();
}
public function getUser()
{
$query = $this->db->query("SELECT * FROM users");
var_dump($query);
}
}
These files are in site/app/model/file.php
I instantiate db in my site/index.php