I have 4 classes:
Main
SQL
Template
Member
. I would like SQL
Template and
Member to extend Main class.
But also, at the same time, I would like to be able to not call all the classes neither require them all at the same time.
So, in my index.phpfile I would call Main and Template.
In my register.php page I would call Main,Template,SQL and Member.
In my submit.php page, I would call Main,SQL and Member.
I have the classes like this:
------ Main Class ------
<?php
public $db;
class Main {
public function __construct(){
}
public function One(){
// here I would call Two, Three, and Four if available
}
}
------ SQL Class ------
<?php
class SQL extends Main {
public function __construct(){
parent::__construct();
$this->db = new mysqli(....);
}
public function Two(){
$this->db->query(.....);
// Fetch query code
echo $result;
}
}
------ Template Class ------
<?php
class SQL extends Main {
public function __construct(){
parent::__construct();
$this->db = new mysqli(....);
}
public function Three(){
$this->db->query(.....);
// Fetch query code
echo $result;
}
}
The Member Class would be identical to the other ones and have the function four..
So, this is how I'm doing it, but I'm not able to call functions from the child classes, only from the main.
Can you please tell me a better way of doing this? Thank you in advance.