當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。