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


PHP Migration::addForeignKey方法代码示例

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


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

示例1: install

 public function install()
 {
     parent::install();
     $migration = new Migration();
     $migration->createTable($this->getTable(), ['id' => Schema::TYPE_PK, 'object_id' => Schema::TYPE_INTEGER, 'term_id' => Schema::TYPE_BIGINT, 'value' => Schema::TYPE_STRING]);
     if ($migration->db->driverName === 'mysql') {
         $migration->addForeignKey('fk_' . $this->getTable() . '_' . $this->getRefTableName(), $this->getTable(), 'object_id', $this->getRefTableName(), 'id', 'CASCADE');
         $migration->addForeignKey('fk_' . $this->getTable() . '_' . TaxonomyTerms::tableName(), $this->getTable(), 'term_id', TaxonomyTerms::tableName(), 'id', 'CASCADE');
     }
 }
开发者ID:traykovn,项目名称:yii2-taxonomy,代码行数:10,代码来源:PropertyTerm.php

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

示例3: runRelations

 /**
  * Relate creations
  * @return bool
  */
 public function runRelations()
 {
     $result = true;
     foreach ($this->relations as $_nextRelation) {
         try {
             if ($this->hideMigrationOutput) {
                 ob_start();
             }
             $result = $this->migrationClass->addForeignKey($_nextRelation['fk_name'], $_nextRelation['table_name'], $_nextRelation['field'], $_nextRelation['related_table'], $_nextRelation['related_field'], 'RESTRICT', 'CASCADE') && $result;
             if ($this->hideMigrationOutput) {
                 ob_clean();
                 ob_flush();
             }
         } catch (\yii\db\Exception $expt) {
         }
     }
     return $result;
 }
开发者ID:infinitydevphp,项目名称:yii2-table-builder,代码行数:22,代码来源:TableBuilder.php

示例4: addForeignKey

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

示例5: addForeignKey

 /**
  * @inheritdoc
  * @param string|null $name
  */
 public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null)
 {
     if (is_null($name)) {
         $name = implode('-', array_merge((array) $table, (array) $columns));
     }
     if (is_null($delete)) {
         $delete = static::RESTRICT;
     }
     if (is_null($update)) {
         $update = static::NO_ACTION;
     }
     parent::addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete, $update);
 }
开发者ID:ivan-chkv,项目名称:yii2-boost,代码行数:17,代码来源:Migration.php

示例6: apply

 public function apply()
 {
     return $this->migrate->addForeignKey($this->getName(), $this->getSourceTable(), $this->getSourceColumn(), $this->getRefTable(), $this->getRefColumn(), $this->getOnDelete(), $this->getOnUpdate());
 }
开发者ID:carono,项目名称:yii2-installer,代码行数:4,代码来源:ForeignKeyColumn.php

示例7: addForeignKeyWithoutIndex

 /**
  * Builds a SQL statement for adding a foreign key constraint to an existing table (without index creation).
  * The method will properly quote the table and column names.
  * @param string $name the name of the foreign key constraint.
  * @param string $table the table that the foreign key constraint will be added to.
  * @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 $refTable the table that the foreign key references to.
  * @param string|array $refColumns the name of the column that the foreign key references to. If there are multiple columns, separate them with commas or use an array.
  * @param string $delete the ON DELETE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
  * @param string $update the ON UPDATE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
  *
  * @see addForeignKey
  */
 public function addForeignKeyWithoutIndex($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null)
 {
     parent::addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete, $update);
 }
开发者ID:nox-it,项目名称:yii2-nox-migration,代码行数:17,代码来源:Migration.php

示例8: addForeignKey

 /**
  * Builds a SQL statement for adding a foreign key constraint to an existing table.
  * The method will properly quote the table and column names.
  * @param string $table the table that the foreign key constraint will be added to.
  * @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 $refTable the table that the foreign key references to.
  * @param string|array $refColumns the name of the column that the foreign key references to. If there are multiple columns, separate them with commas or use an array.
  * @param string $delete the ON DELETE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
  * @param string $update the ON UPDATE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
  * @param string $name the name of the foreign key constraint.
  */
 public function addForeignKey($table, $columns, $refTable, $refColumns, $delete = 'CASCADE', $update = 'CASCADE', $name = null)
 {
     $name = $name ?: $this->getNameForeignKey($table, $columns);
     parent::addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete, $update);
 }
开发者ID:lav45,项目名称:yii2-db-migrate,代码行数:16,代码来源:Migration.php

示例9: addForeignKey

 public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null)
 {
     if (is_null($name)) {
         $name = self::formFkName($table, $columns, $refTable, $refColumns);
     }
     return parent::addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete, $update);
 }
开发者ID:carono,项目名称:yii2-installer,代码行数:7,代码来源:Migration.php


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