There is a connection class to db:
class DataBase { public static $db = null; public $msqli; public static function getDb() { if (self::$db == null) { self::$db = new DataBase(); } return self::$db; } private function __construct() { $this->msqli = mysqli_connect('localhost', 'root', '', 'depsoft'); } public function __destruct() { if ($this->msqli) { $this->msqli->close(); } } } There is a class inheriting from it in another file that performs some other functions:
require_once "connect.php"; class DateFormToInsert extends DataBase { public static function dateFromToInsert() { $query_user = mysqli_query($this->msqli, "SELECT * FROM `region_table`"); $data = mysqli_fetch_array($query_user, MYSQLI_ASSOC); echo "<pre>"; print_r($data); } } $aa = DateFormToInsert::getDb(); DateFormToInsert::dateFromToInsert(); Is this approach correct? Before that, I did not try to write to the op. And the second question is how to get access to $ this-> msqli defined in the parent in the child class?