I have MysqliDb https://github.com/joshcam/PHP-MySQLi-Database-Class.
In my php class:
<?php
require_once ('MysqliDb.php');
class Main{
protected $db;
public function __construct()
{
$this->db = new MysqliDb ('localhost', 'root', 'tuncay', 'db');
}
}
Class A extends Main{
public function __construct()
{
$this->db = MysqliDb::getInstance();
echo $this->db->where("id", 5)->getOne('test')['text'];
}
}
$a = new A();
?>
Fatal error: Call to a member function where() on null in /.../db/index.php on line 21 where() function belongs MysqliDb.php
What is wrong? I got $this->db from Main class
I just want to keep DB connection in A class and use it.