I have a core class which loads two extending classes; each stored in public vars.
Code: Select all
# all files loaded before core instantiated
class core {
public $sql, $user;
public function __construct() {
$this->sql = new sql;
$this->user = new user;
}
public function clean($input) {
...
return $cleaned;
}
}Code: Select all
class user extends core {
public function __construct() {
if (isset($_POST['username']) && isset($_POST['password'])) {
$this->login();
}
}
private function login() {
// THIS WORKS FINE
$username = parent::clean($_POST['username']);
// HERE'S THE PROBLEM, I CAN'T GET AT THE EXTENDING SQL CLASS' FUNCTIONS
$sql = sprintf("SELECT * FROM `users` WHERE `username`='%s' LIMIT 1", parent::sql::escape($username));
/*
I've tried variations such as:
core::sql::escape();
core->sql->escape();
and I've tried making $core available via $this->core
and I've tried making $sql static in the core
...but nothing's working!
*/
}
}Thanks, Ben.