Пример #1
0
 private static function find_or_create_schema_migrations_table()
 {
     if (!in_array('schema_migrations', moojon_db::show_tables(''))) {
         moojon_db::create_table('schema_migrations', array(new moojon_string_column('version')));
     }
 }
 protected final function create_table($name, $data, $options = null)
 {
     if (!is_array($data)) {
         $data = array($data);
     }
     foreach ($data as $column) {
         if ($column->get_name() == moojon_primary_key::NAME) {
             $this->primary_key = null;
         } else {
             if ($column->get_name() == 'created_on') {
                 $this->created_on = null;
             } else {
                 if ($column->get_name() == 'updated_at') {
                     $this->updated_at = null;
                 }
             }
         }
     }
     if ($this->primary_key) {
         array_unshift($data, $this->primary_key);
     }
     if ($this->created_on) {
         array_push($data, $this->created_on);
     }
     if ($this->updated_at) {
         array_push($data, $this->updated_at);
     }
     moojon_db::create_table($name, $data, $options);
 }