Esempio n. 1
0
File: MPT.php Progetto: techart/tao
 public static function schema(&$data, $create_join_table = true)
 {
     $table = $data['name'];
     if (!isset($data['columns']['parent_id'])) {
         $data['columns']['parent_id'] = array('type' => 'int', 'default' => '0', 'not null' => true);
         $data['indexes']["idx_{$table}_parent_id"] = array('columns' => array('parent_id'));
     }
     if ($create_join_table && !empty($data['name'])) {
         $table = $data['name'] . '_tree';
         $join_schema = array($table => array());
         self::schema_join($join_schema[$table], $table);
         DB_Schema::process($join_schema);
     }
 }
Esempio n. 2
0
 static function process_schema($table, $fields, $engine = false)
 {
     Core::load('DB.Schema');
     $table_schema = self::fields_to_schema($fields, $table);
     if ($engine) {
         $table_schema['mysql_engine'] = $engine;
     }
     DB_Schema::process(array($table => $table_schema));
     foreach ($fields as $name => $data) {
         $type = self::type($data);
         $type->process_schema($name, $data, $table, $fields);
     }
 }
Esempio n. 3
0
 public static function process_file($file, $cache = true, $connection = null, $force_update = false)
 {
     if (is_file($file)) {
         $schema = (include $file);
         if ($cache === true) {
             $cache = WS::env()->cache;
         }
         return DB_Schema::process($schema, $connection, $force_update, $cache);
     }
     return false;
 }