i dunno if anyone is interested but i solved it here is the result. this is good to build an actionModel for example and then inherit em methods only use what you need and make a new instance of the child for db insertion. use the instance and mail subjects with the same data etc, this is to the fact of no late static bindings and I didnt have time to go figure out how to make it work so just did this so if phpversion is less then 5.3 you can use this. otherwise just go with late static bindings.
i tested it on 5.2.14 http://aquaregiafx.com/test.php it works tomorrow at work i can test it on 5.2.6 and cross my fingers it works cuz that will make my life so much more simpler.
<?php
class test {
public function show(array $array) {
$this->set($array);
return $this->get();
}
protected function find(array $row) {
$object_array= array();
foreach($row as $record):
$object_array[] = $this->instantiate($record);
endforeach;
return $object_array;
}
private function instantiate(array $record) {
// Could check that $record exists and is an array
foreach ($record as $attribute => $value):
if ($this->has_attribute($attribute)) {
$this->$attribute = $value;
}
endforeach;
return $this->get();
}
private function has_attribute($attribute) {
// get_object_vars returns an associative array with all attributes
// excluding static vars
$object_vars = $this->get();
return array_key_exists($attribute, $object_vars);
}
private function set(array $array) {
foreach($array as $k => $v):
$this->$k = $v;
endforeach;
}
private function get() {
return get_object_vars($this);
}
}
class more extends test {
protected $id = '1'; // protected for parent
protected $name = '2'; // private from sibling :))
public function set_more() {
$row = array(array("id" => "igoreee"),array("id" => "max"));
return parent::find($row);
}
}
$a = new more;
print '<pre>';
print_r($a->set_more());
print '</pre>';
print '<br />';
print '<hr />' . phpversion();
?>
Hint, if you are to build a table model and the model requires other fields that are in the database table all you have to do is use static keyword for the property to hide it from the get_object_vars() very usefull to store flags or counter.