コード例 #1
0
ファイル: OrmDbCreation.php プロジェクト: ahri/orm
     }
     if (!is_null($o->parent)) {
         foreach ($objs[$o->parent]->keys as $key) {
             $rowMatch = rowMatch($orm_name, $o->parent, $key);
             $properties[] = sprintf("    %s__key__%s %s%s%s", Orm::classToDbName(Orm::RELATIONSHIP_INHERITS), $rowMatch->name, $rowMatch->type, $rowMatch->length, $rowMatch->default);
         }
     }
     $relationships = array();
     foreach ($o->relationships as $rship => $class) {
         foreach ($objs[$class]->keys as $key) {
             $rowMatch = rowMatch($orm_name, $class, $key);
             $properties[] = sprintf("    %s__key__%s %s%s%s", Orm::classToDbName($rship), $rowMatch->name, $rowMatch->type, $rowMatch->length, $rowMatch->default);
         }
         foreach ($objs[$rship]->properties as $p) {
             $rowMatch = rowMatch($orm_name, $rship, $p);
             $properties[] = sprintf("    %s__var__%s %s%s%s", Orm::classToDbName($rship), $rowMatch->name, $rowMatch->type, $rowMatch->length, $rowMatch->default);
         }
     }
     if (sizeof($o->keys) > 0) {
         $properties[] = sprintf('    PRIMARY KEY (%s)', implode(', ', $o->keys));
     }
     $schema .= sprintf("%s\n);\n\n", implode(",\n", array_merge($properties, $relationships)));
 }
 $form = $body->form();
 $form->method = 'post';
 $on = $form->input();
 $on->type = 'hidden';
 $on->name = 'orm_name';
 $on->value = $_POST['orm_name'];
 $textarea = $form->textarea($schema, Node::UNMANGLED);
 $textarea->name = 'schema';