public function hasDefaultValue() { if ($this->Null == 'YES') { return true; } return !MormUtils::isEmpty($this->Default); }
protected function fillOtherValues($instance) { $tabledesc = $instance->getTableDesc(); $fields = $tabledesc->getFields(); foreach ($fields as $field_name => $field) { $value = NULL; if (!$field->hasDefaultValue() && MormUtils::isEmpty($instance->{$field_name})) { if ($field->type == 'enum' || $field->type == 'set') { // random is much funny $value = $field->values[rand(0, count($field->values) - 1)]; } elseif ($field->php_type == 'string') { $value = md5(rand(0, 10000)); } elseif ($field->isNumeric() && !$field->isAutoIncrement()) { $value = rand(); } $instance->{$field_name} = $value; } } }
/** * @todo replace all call by MormUtils::isEmpty */ private function isEmpty($val) { return MormUtils::isEmpty($val); }