laserlight;10997999 wrote:What have you tried?
Well..this is what i've tried..
protected function variable_initialize() {
$fields = self::find_fields();
foreach($fields as $field) {
$this->$field = NULL;
}
}
the find_fields() method is another method that i wrote in the database class that returns the names of the fields one after the other in order. The above method sort of works..but i would like the variable to be defined as static. Also, with this, I'll have to manually call this method in every class that I write. I have'nt worked out how to bypass the $this->$field in a static context.
At present, saving values into the database will happen even without this initialization. However, retrieving values from the Database requires these variables to be defined and i haven't worked out how i can integrate that into my custom find_by_id method that i wrote in the database class.