help with singleton mysqli database object in extended class



The last line of the code below is my problem -- when I instantiate
the Child object, Base::writeData() runs fine and performs my query,
but then the Child::writeData() function does not execute a query.
Everything works fine except I cannot query the database from within
the Child extended class because it can't seem to access the $db
object. I've tried overriding the Base::__construct() and fiddling
with member and method overrides and scopes ad nauseum. PLEASE take a
look at the code below and HELP ME. Many thanks :-)


class Database{

protected static $db;
private function __construct(){}
public static function getInstance(){

if ( !isset(self::$db) ){
self::$db = new mysqli('host', 'user', 'pass', 'db');
}
return self::$db;

}
}

class Base{

protected static $db;

function __construct(){
$this->db = Database::getInstance();
}

function writeData($data){

$query = "..."
$this->db->query($query)

}
}

class Child extends Base{

function writeData($data){

$query = "..."
$this->db->query($query)

}
}

$test = new Child();
$test->writeData($data);
.



Relevant Pages

  • Re: Query vs form with child & parent: Deleting rows
    ... subordinate to that record, that is, all individuals (and sometimes child ... companies) whose Owner field contains the record key of the parent company. ... That second form is fed by this query: ... But I have a child table called "Channel"; ...
    (microsoft.public.access.forms)
  • Re: SQL Statement - Form/SubForm
    ... table out of the sub form in the control tab if the user clicks saves on the ... All you have to do is change that sub-form on the tab to a regular bunch of ... So, to do this, you just built a nice query in the query builder. ... Now drop in the child table. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Two tables / one to many relationship - need single record
    ... Convert the query to a crosstab, specifying File as row hearder, Child / DOB ... The desired recordset would include the needed client ...
    (microsoft.public.access.queries)
  • Re: Queries involving subforms
    ... If you create your query, with the parent & child tables joined, and add the ... you will get as many as there are child rows ...
    (microsoft.public.access.queries)
  • Excluding related records and a subquery NOT IN clause
    ... Tables: Master, Child ... What I want to do is filter out certain attributes using a query, recordset, ... AttrIDNum is in the table Exclude. ...
    (microsoft.public.access.queries)