示例#1
0
文件: FieldDesc.php 项目: AF83/morm
 public function hasDefaultValue()
 {
     if ($this->Null == 'YES') {
         return true;
     }
     return !MormUtils::isEmpty($this->Default);
 }
示例#2
0
文件: MormFactory.php 项目: AF83/morm
 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;
         }
     }
 }
示例#3
0
文件: Morm.php 项目: anicet/morm
 /**
  * @todo replace all call by MormUtils::isEmpty
  */
 private function isEmpty($val)
 {
     return MormUtils::isEmpty($val);
 }