size = $size; $this->label = $label; } } class CharField extends Field { function __construct($size = 80, $label = '') { $this->editor = 'input type="text"'; parent::__construct($size, $label); } function get_db_type() { return 'VARCHAR('.$this->size.')'; } } class Model { function get_name() { return get_class($this); } function make_create_sql() { $str = ''; echo "\nCREATE TABLE `",strtolower($this->get_name()),"` (\n"; echo " `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,\n"; foreach ( get_class_vars($this->get_name()) as $x => $y) { echo ' `',$x,'` ',$this->$x->get_db_type(),",\n"; } echo ");\n\n"; } function make_form() { foreach ( get_class_vars($this->get_name()) as $x => $y) { echo $this->$x->label,': <',$this->$x->editor,' name="',$x,"\">\n"; } } function make_form_table() { echo "
| ',$this->$x->label,' | <', $this->$x->editor,' name="',$x,'" value="'.$this->$x->value. "\"> |
|---|