This isn't working the way I thought it would. Here are my classes:
class App {
public $db;
public function __construct($db) {
$this->db = $db;
}
}
class Analysis extends App {
public $analysis_id;
public function __construct($analysis_id) {
$this->analysis_id = $analysis_id;
}
}
class Standard extends Analysis {
public function __construct($analysis_id) {
parent::__construct($analysis_id);
}
}
$db
is my database (mysqli) object that I've passed to the App class.
When I try to perform a new Standard Analysis, I initiate it like this:
$analysis = new Standard($analysis_id);
The Analysis class contains methods that retrieve meta data about an analysis, while the Standard class contains methods that retrieve calculations for that specific type of analysis. I thought I would be able to access the $db
object, but I can't from the Analysis or Standard class. Do I need to pass the $db
object to the Standard class when I initiate it?