当前位置: 首页>>代码示例>>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;未经允许,请勿转载。