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


PHP AbstractSchemaManager::createForeignKey方法代碼示例

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


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

示例1: testListForeignKeys

    public function testListForeignKeys()
    {
        if(!$this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) {
            $this->markTestSkipped('Does not support foreign key constraints.');
        }

        $this->createTestTable('test_create_fk1');
        $this->createTestTable('test_create_fk2');

        $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
            array('foreign_key_test'), 'test_create_fk2', array('id'), 'foreign_key_test_fk', array('onDelete' => 'CASCADE')
        );

        $this->_sm->createForeignKey($foreignKey, 'test_create_fk1');

        $fkeys = $this->_sm->listTableForeignKeys('test_create_fk1');

        $this->assertEquals(1, count($fkeys), "Table 'test_create_fk1' has to have one foreign key.");
        
        $this->assertType('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]);
        $this->assertEquals(array('foreign_key_test'),  array_map('strtolower', $fkeys[0]->getLocalColumns()));
        $this->assertEquals(array('id'),                array_map('strtolower', $fkeys[0]->getForeignColumns()));
        $this->assertEquals('test_create_fk2',          strtolower($fkeys[0]->getForeignTableName()));

        if($fkeys[0]->hasOption('onDelete')) {
            $this->assertEquals('CASCADE', $fkeys[0]->getOption('onDelete'));
        }
    }
開發者ID:pmjones,項目名稱:php-framework-benchmarks,代碼行數:28,代碼來源:SchemaManagerFunctionalTestCase.php

示例2: testListForeignKeysComposite

 public function testListForeignKeysComposite()
 {
     if (!$this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) {
         $this->markTestSkipped('Does not support foreign key constraints.');
     }
     $this->_sm->createTable($this->getTestTable('test_create_fk3'));
     $this->_sm->createTable($this->getTestCompositeTable('test_create_fk4'));
     $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('id', 'foreign_key_test'), 'test_create_fk4', array('id', 'other_id'), 'foreign_key_test_fk');
     $this->_sm->createForeignKey($foreignKey, 'test_create_fk3');
     $fkeys = $this->_sm->listTableForeignKeys('test_create_fk3');
     $this->assertEquals(1, count($fkeys), "Table 'test_create_fk3' has to have one foreign key.");
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\ForeignKeyConstraint', $fkeys[0]);
     $this->assertEquals(array('id', 'foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns()));
     $this->assertEquals(array('id', 'other_id'), array_map('strtolower', $fkeys[0]->getForeignColumns()));
 }
開發者ID:llinder,項目名稱:FrameworkBenchmarks,代碼行數:15,代碼來源:SchemaManagerFunctionalTestCase.php

示例3: createForeignKey

 /**
  * {@see AbstractSchemaManager::createForeignKey}
  */
 public function createForeignKey(ForeignKeyConstraint $foreignKey, $table)
 {
     $this->manager->createForeignKey($foreignKey, $this->replacePrefix($table));
 }
開發者ID:enyaku,項目名稱:myGoogleMapsApiV3Test,代碼行數:7,代碼來源:Utility.php


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