<small id='NgAtr'></small><noframes id='NgAtr'>

    1. <tfoot id='NgAtr'></tfoot>
        <bdo id='NgAtr'></bdo><ul id='NgAtr'></ul>

      <legend id='NgAtr'><style id='NgAtr'><dir id='NgAtr'><q id='NgAtr'></q></dir></style></legend>

        <i id='NgAtr'><tr id='NgAtr'><dt id='NgAtr'><q id='NgAtr'><span id='NgAtr'><b id='NgAtr'><form id='NgAtr'><ins id='NgAtr'></ins><ul id='NgAtr'></ul><sub id='NgAtr'></sub></form><legend id='NgAtr'></legend><bdo id='NgAtr'><pre id='NgAtr'><center id='NgAtr'></center></pre></bdo></b><th id='NgAtr'></th></span></q></dt></tr></i><div id='NgAtr'><tfoot id='NgAtr'></tfoot><dl id='NgAtr'><fieldset id='NgAtr'></fieldset></dl></div>

      1. Yii 迁移,不创建表

        时间:2023-08-17

          <tbody id='HGOvP'></tbody>

          <tfoot id='HGOvP'></tfoot>

          <i id='HGOvP'><tr id='HGOvP'><dt id='HGOvP'><q id='HGOvP'><span id='HGOvP'><b id='HGOvP'><form id='HGOvP'><ins id='HGOvP'></ins><ul id='HGOvP'></ul><sub id='HGOvP'></sub></form><legend id='HGOvP'></legend><bdo id='HGOvP'><pre id='HGOvP'><center id='HGOvP'></center></pre></bdo></b><th id='HGOvP'></th></span></q></dt></tr></i><div id='HGOvP'><tfoot id='HGOvP'></tfoot><dl id='HGOvP'><fieldset id='HGOvP'></fieldset></dl></div>
              • <legend id='HGOvP'><style id='HGOvP'><dir id='HGOvP'><q id='HGOvP'></q></dir></style></legend>
                  <bdo id='HGOvP'></bdo><ul id='HGOvP'></ul>

                • <small id='HGOvP'></small><noframes id='HGOvP'>

                  本文介绍了Yii 迁移,不创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是 Yii 的新手(仍在学习)我正在学习一本书教程在这里,我按照书中写的那样创建了一个新的迁移

                  I am new to Yii(Still Learning) I am following a book tutorial here I did as it was written in the book created a new migrate

                  yiic migrate create create_issue_user_and_assignment_tables
                  

                  在safeup中我写了这个查询

                  and in safeup I wrote this query

                  $this->createTable('tbl_issue', array(
                  'id' => 'pk',
                  'name' => 'string NOT NULL',
                  'description' => 'text',
                  'project_id' => 'int(11) DEFAULT NULL',
                  'type_id' => 'int(11) DEFAULT NULL',
                  'status_id' => 'int(11) DEFAULT NULL',
                  'owner_id' => 'int(11) DEFAULT NULL',
                  'requester_id' => 'int(11) DEFAULT NULL',
                  'create_time' => 'datetime DEFAULT NULL',
                  'create_user_id' => 'int(11) DEFAULT NULL',
                  'update_time' => 'datetime DEFAULT NULL',
                  'update_user_id' => 'int(11) DEFAULT NULL',
                  ), 'ENGINE=InnoDB');
                  //create the user table
                  $this->createTable('tbl_user', array(
                  'id' => 'pk',
                  'username' => 'string NOT NULL',
                  'email' => 'string NOT NULL',
                  'password' => 'string NOT NULL',
                  'last_login_time' => 'datetime DEFAULT NULL',
                  'create_time' => 'datetime DEFAULT NULL',
                  'create_user_id' => 'int(11) DEFAULT NULL',
                  'update_time' => 'datetime DEFAULT NULL',
                  'update_user_id' => 'int(11) DEFAULT NULL',
                  ), 'ENGINE=InnoDB');
                  

                  这在 safeDown() 中

                  and this in safeDown()

                  $this->dropTable('tbl_issue');
                  $this->dropTable('tbl_user');
                  

                  然后运行它并得到以下消息

                  then run it and got the following msg

                  D:wampwwwyiisiteprotected>yiic migrate
                  PHP Deprecated:  Directive 'register_globals' is deprecated in PHP 5.3 and great
                  er in Unknown on line 0
                  
                  Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in
                   Unknown on line 0
                  
                  Yii Migration Tool v1.0 (based on Yii v1.1.13)
                  
                  Total 1 new migration to be applied:
                      m130703_085302_create_issue_user_and_assignment_tables
                  
                  Apply the above migration? (yes|no) [no]:yes
                  *** applying m130703_085302_create_issue_user_and_assignment_tables
                  *** applied m130703_085302_create_issue_user_and_assignment_tables (time: 0.042s
                  )
                  
                  
                  Migrated up successfully.
                  

                  现在的问题是没有在数据库中创建表,这可能是因为 register_globals 已被弃用,但我不知道该怎么做,连接参数正确并且在表中插入了一条记录 tbl_migration

                  now the problem is that tables are not created in the database it may be because of the msg that register_globals is deprecated but I am not sure what to do, connection parameters are correct and a record was inserted in the table tbl_migration

                  m130703_085302_create_issue_user_and_assignment_ta...   1372842220
                  

                  但没有创建新表.

                  推荐答案

                  创建表通常不需要事务

                  <?php
                  class m130630_124600_some_description_name extends CDbMigration
                  {
                      public function up(){
                          //upcode example create the session table
                          $this->createTable('session',[
                               'id' => "varchar(40) NOT NULL",
                               'expire' => "int(12)",
                               'data' => "blob",
                          ]);
                          $this->addPrimaryKey('idx','session','id');
                      }
                      public function down(){
                         // downcode (undo the up code) example: drop session table
                         $this->dropTable('session');
                      }
                  }
                  

                  <小时>

                  如果需要交易

                  遵循safeUp的评论:

                  这个方法包含了应用这个时要执行的逻辑移民.此方法与 up() 的不同之处在于 DB 逻辑这里实现的将包含在一个 DB 事务中.孩子如果数据库逻辑,类可以实现此方法而不是 up()需要在一个事务中.

                  This method contains the logic to be executed when applying this migration. This method differs from up() in that the DB logic implemented here will be enclosed within a DB transaction. Child classes may implement this method instead of up() if the DB logic needs to be within a transaction.

                  这篇关于Yii 迁移,不创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Yii - 如何通过管理页面上的外键/相关键的列进行搜索? 下一篇:在 yii 中从 csv 文件导入和保存数据

                  相关文章

                  1. <small id='r0eLM'></small><noframes id='r0eLM'>

                    <legend id='r0eLM'><style id='r0eLM'><dir id='r0eLM'><q id='r0eLM'></q></dir></style></legend>
                      • <bdo id='r0eLM'></bdo><ul id='r0eLM'></ul>
                      <i id='r0eLM'><tr id='r0eLM'><dt id='r0eLM'><q id='r0eLM'><span id='r0eLM'><b id='r0eLM'><form id='r0eLM'><ins id='r0eLM'></ins><ul id='r0eLM'></ul><sub id='r0eLM'></sub></form><legend id='r0eLM'></legend><bdo id='r0eLM'><pre id='r0eLM'><center id='r0eLM'></center></pre></bdo></b><th id='r0eLM'></th></span></q></dt></tr></i><div id='r0eLM'><tfoot id='r0eLM'></tfoot><dl id='r0eLM'><fieldset id='r0eLM'></fieldset></dl></div>
                      <tfoot id='r0eLM'></tfoot>