當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Migration::dropForeignKey方法代碼示例

本文整理匯總了PHP中yii\db\Migration::dropForeignKey方法的典型用法代碼示例。如果您正苦於以下問題:PHP Migration::dropForeignKey方法的具體用法?PHP Migration::dropForeignKey怎麽用?PHP Migration::dropForeignKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\db\Migration的用法示例。


在下文中一共展示了Migration::dropForeignKey方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionUpdate

 /**
  * Update ip-geo-base data
  *
  * @throws \yii\base\Exception
  */
 public function actionUpdate()
 {
     $migrate = new Migration();
     $migrate->dropForeignKey('fk-geobase_contact-geobase_city_id', 'geobase_contact');
     $ipGeoBase = new IpGeoBase();
     $ipGeoBase->updateDB();
     $migrate->addForeignKey('fk-geobase_contact-geobase_city_id', 'geobase_contact', 'geobase_city_id', 'geobase_city', 'id', 'CASCADE', 'CASCADE');
 }
開發者ID:mark38,項目名稱:yii2-site-mng,代碼行數:13,代碼來源:DefaultController.php

示例2: 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

示例3: dropForeignKey

 /**
  * @inheritdoc
  * Note: table will be auto pefixied if [[$autoWrapTableNames]] is true.
  */
 public function dropForeignKey($name, $table)
 {
     $table = $this->autoWrappedTableName($table);
     return parent::dropForeignKey($name, $table);
 }
開發者ID:flexibuild,項目名稱:migrate,代碼行數:9,代碼來源:Migration.php

示例4: remove

 public function remove()
 {
     return $this->migrate->dropForeignKey($this->getName(), $this->getSourceTable());
 }
開發者ID:carono,項目名稱:yii2-installer,代碼行數:4,代碼來源:ForeignKeyColumn.php

示例5: dropForeignKey

 /**
  * @inheritdoc
  */
 public function dropForeignKey($name, $table)
 {
     $indexName = $name;
     if (preg_match('/\\}\\}$/', $indexName)) {
         $indexName = preg_replace('/^(.*)\\}\\}$/', '$1_idx}}', $indexName);
     } else {
         $indexName .= '_idx';
     }
     parent::dropForeignKey($name, $table);
     $this->dropIndex($indexName, $table);
 }
開發者ID:nox-it,項目名稱:yii2-nox-migration,代碼行數:14,代碼來源:Migration.php

示例6: dropForeignKey

 /**
  * Builds a SQL statement for dropping a foreign key constraint.
  * @param string $table the table whose foreign is to be dropped. The name will be properly quoted by the method.
  * @param string|array $columns the name of the column to that the constraint will be added on. If there are multiple columns, separate them with commas or use an array.
  * @param string $name the name of the foreign key constraint to be dropped. The name will be properly quoted by the method.
  */
 public function dropForeignKey($table, $columns, $name = null)
 {
     $name = $name ?: $this->getNameForeignKey($table, $columns);
     parent::dropForeignKey($name, $table);
 }
開發者ID:lav45,項目名稱:yii2-db-migrate,代碼行數:11,代碼來源:Migration.php


注:本文中的yii\db\Migration::dropForeignKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。