当前位置: 首页>>代码示例>>PHP>>正文


PHP Migration::dropTable方法代码示例

本文整理汇总了PHP中yii\db\Migration::dropTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::dropTable方法的具体用法?PHP Migration::dropTable怎么用?PHP Migration::dropTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\db\Migration的用法示例。


在下文中一共展示了Migration::dropTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dropTable

 public function dropTable()
 {
     if ($this->dropOriginTable) {
         if (in_array($this->tableNameRaw, $this->_connection->schema->tableNames)) {
             $schema = $this->_connection->schema->getTableSchema($this->tableNameRaw);
             if ($schema) {
                 $keys = $schema->foreignKeys;
                 if (is_array($keys)) {
                     foreach ($keys as $name => $_next) {
                         $t = [];
                         foreach ($_next as $k => $v) {
                             if (!$k) {
                                 $t['related_table'] = $v;
                             } else {
                                 $t['related_field'] = $v;
                                 $t['field'] = $k;
                             }
                         }
                         try {
                             $keyName = $this->getNameForeignKey($this->tableNameRaw, $t['related_table'], $_next[$t['field']], $t['related_field'], 255);
                             if ($this->hideMigrationOutput) {
                                 ob_start();
                             }
                             $this->migrationClass->dropForeignKey($keyName, $this->tableNameRaw);
                             if ($this->hideMigrationOutput) {
                                 ob_clean();
                                 ob_flush();
                             }
                         } catch (\yii\db\Exception $exp) {
                         }
                     }
                 }
                 if ($this->hideMigrationOutput) {
                     ob_start();
                 }
                 try {
                     $this->migrationClass->dropTable($this->tableNameRaw);
                 } catch (\yii\db\Exception $exp) {
                 } catch (IntegrityException $exp) {
                 }
                 if ($this->hideMigrationOutput) {
                     ob_clean();
                     ob_flush();
                 }
             }
         }
     }
 }
开发者ID:infinitydevphp,项目名称:yii2-table-builder,代码行数:48,代码来源:TableBuilder.php

示例2: afterDelete

 /**
  * @inheritdoc
  */
 public function afterDelete()
 {
     parent::afterDelete();
     $migrate = new Migration();
     $table = self::getTable($this->tab_index, $this->tab);
     $migrate->dropTable($table);
     //return true;
 }
开发者ID:jackieit,项目名称:aimocms,代码行数:11,代码来源:Cm.php

示例3: dropTable

 /**
  * @inheritdoc
  * Note: table will be auto pefixied if [[$autoWrapTableNames]] is true.
  */
 public function dropTable($table)
 {
     $table = $this->autoWrappedTableName($table);
     return parent::dropTable($table);
 }
开发者ID:flexibuild,项目名称:migrate,代码行数:9,代码来源:Migration.php

示例4: migrateDown

 /**
  * @param Migration $migration
  * @param string $tableName
  */
 public static function migrateDown($migration, $tableName = '{{%files}}')
 {
     $migration->dropTable($tableName);
 }
开发者ID:omnilight,项目名称:yii2-models,代码行数:8,代码来源:FileMigration.php


注:本文中的yii\db\Migration::dropTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。