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


PHP Blueprint::foreign方法代码示例

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


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

示例1: buildDynamicTable

 protected function buildDynamicTable(Blueprint $table)
 {
     $block_index = 'FK_' . $this->getDynamicTableName() . '_block_id_blocks';
     $page_index = 'FK_' . $this->getDynamicTableName() . '_page_id_pages';
     $table->increments('id');
     $table->integer('block_id')->unsigned()->nullable();
     $table->integer('page_id')->unsigned()->nullable();
     $table->integer('is_shared')->unsigned()->nullable();
     $table->foreign('block_id', $block_index)->references('id')->on('blocks')->onUpdate('CASCADE')->onDelete('SET NULL');
     $table->foreign('page_id', $page_index)->references('id')->on('pages')->onUpdate('CASCADE')->onDelete('SET NULL');
     $table->timestamps();
 }
开发者ID:sodacms,项目名称:sodacms,代码行数:12,代码来源:BlockType.php

示例2: buildDynamicTable

 protected function buildDynamicTable(Blueprint $table)
 {
     $reference_column = $this->getDynamicType() . '_id';
     $reference_table = $this->getDynamicType() . 's';
     $reference_index = 'FK_' . $this->getDynamicTableName() . '_' . $reference_column . '_' . $reference_table;
     $table->increments('id');
     $table->integer($reference_column)->unsigned()->nullable();
     $table->foreign($reference_column, $reference_index)->references('id')->on($reference_table)->onUpdate('CASCADE')->onDelete('SET NULL');
     $table->timestamps();
 }
开发者ID:sodacms,项目名称:sodacms,代码行数:10,代码来源:AbstractDynamicType.php

示例3: testAddingForeignKey

 public function testAddingForeignKey()
 {
     $blueprint = new Blueprint('users');
     $blueprint->foreign('foo_id')->references('id')->on('orders');
     $statements = $blueprint->toSql($this->getGrammar());
     $this->assertEquals(1, count($statements));
     $this->assertEquals('alter table `users` add constraint users_foo_id_foreign foreign key (`foo_id`) references `orders` (`id`)', $statements[0]);
 }
开发者ID:hochanh,项目名称:Bootsoft-Bowling,代码行数:8,代码来源:MySqlSchemaGrammarTest.php

示例4: testAddingForeignKeyWithCascadeDelete

 public function testAddingForeignKeyWithCascadeDelete()
 {
     $blueprint = new Blueprint('users');
     $blueprint->foreign('foo_id')->references('id')->on('orders')->onDelete('cascade');
     $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
     $this->assertEquals(1, count($statements));
     $this->assertEquals('alter table users add constraint users_foo_id_foreign foreign key ( foo_id ) references orders ( id ) on delete cascade', $statements[0]);
 }
开发者ID:mickael83,项目名称:Laravel-OracleDB,代码行数:8,代码来源:OracleDBSchemaGrammarTest.php

示例5: testAddingForeignKey

 public function testAddingForeignKey()
 {
     $blueprint = new Blueprint('users');
     $blueprint->create();
     $blueprint->string('foo')->primary();
     $blueprint->string('order_id');
     $blueprint->foreign('order_id')->references('id')->on('orders');
     $statements = $blueprint->toSql($this->getGrammar());
     $this->assertEquals(1, count($statements));
     $this->assertEquals('create table "users" ("foo" varchar not null, "order_id" varchar not null, foreign key("order_id") references "orders"("id"), primary key ("foo"))', $statements[0]);
 }
开发者ID:hochanh,项目名称:Bootsoft-Bowling,代码行数:11,代码来源:SQLiteSchemaGrammarTest.php

示例6: createKey

 /**
  * Create a foreign key on the given table.
  *
  * @param  \Illuminate\Database\Schema\Blueprint   $table
  * @param  \Stidges\LaravelFkMigration\ForeignKey  $key
  * @return void
  */
 protected function createKey(Blueprint $table, ForeignKey $key)
 {
     $table->foreign($key->column)->references($key->references)->on($key->on)->onUpdate($key->onUpdate)->onDelete($key->onDelete);
 }
开发者ID:ymnl007,项目名称:laravel-fk-migration,代码行数:11,代码来源:Migration.php


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