Forum Moderators: coopster
Would I use a "parent", "interface" or "abstract" structure to do this? and more importantly, will the magic still work from an upper tier!?
Here are my magic funcs that I want to put in an upper tier...
// define attributes
private $data;
private $dbh;// start by connecting to DB and creating an option object
public function __construct($data = array())
{
foreach($data as $key => $value)
{
$this->$key = $value;
}
$this->dbh = DBConnect(DB_DSN_THESOURCE,true,true);
}
// when finished, disconnect from DB
public function __distruct() {
DBDisconnect($dbh);
}
// get attributes
private function __get($key) {
if(isset($this->data[$key])) {
return $this->data[$key];
}
return false;
}
// set attributes
private function __set($key, $value) {
$this->data[$key] = $value;
}
If you wanted to override it in ClassName in certain conditions, here is an example of how you could do that:
bigFunction($argument){
if($argument>=10){
return "$argument is greater than or equal to 10";
}else{
parent::bigFunction();
}
}