Static Variables and self construction
Posted: Tue Jul 06, 2010 5:23 pm
I am using php 5.3. If you are not familiar with late static bindings please be advised this post involves late static bindings.
The functions below will successfully create variables based on the database fields associated with the class.
What I need the construction function to do is to make the variables static when it creates them.
*** Product Class ***
*** Common Class ***
Thank you for your help.
Mike
The functions below will successfully create variables based on the database fields associated with the class.
What I need the construction function to do is to make the variables static when it creates them.
*** Product Class ***
Code: Select all
class Product extends Common {
protected static $table_name = 'products';
protected static $db_fields;
public function __construct(){
self::construction ();
}
}
$product = new Product;
Code: Select all
class Common {
protected function construction () {
$this->db_fields = self::find_table_fields();
foreach($this->db_fields as $key => $field){
$this->$field = "";
}
}
}
Mike