diff --git a/class.databaserecord.php b/class.databaserecord.php index 60144be..908216f 100644 --- a/class.databaserecord.php +++ b/class.databaserecord.php @@ -72,6 +72,7 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass else { $bind_datasets = false; + $this->FillDefaults(); } } elseif(is_object($uDataSource)) @@ -209,6 +210,36 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass } } + public function FillDefaults() + { + foreach($this->prototype as $type => $dataset) + { + switch($type) + { + case "string": + $default_value = ""; + break; + case "numeric": + $default_value = 0; + break; + case "boolean": + $default_value = false; + break; + case "timestamp": + $default_value = 0; + break; + default: + continue 2; + } + + foreach($dataset as $property) + { + $variable_name = "s" . $property; + $this->$variable_name = $default_value; + } + } + } + public function DoRenderInternalTemplate() { if(!empty($this->render_template))