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);
.