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


PHP Table::addNamedForeignKeyConstraint方法代码示例

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


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

示例1: defineLocality

 /**
  * Defines the locality columns and constraints
  * 
  * @param string $locality Locality type name
  * @param Table  $table    Database table
  * @param string $version  Bundle version
  */
 protected function defineLocality($locality, Table $table, $version)
 {
     switch (true) {
         // Version 0.1.0
         case version_compare($version, "0.1.0", '>='):
             $table->addColumn('id', 'integer')->setUnsigned(true)->setNotNull(true)->setAutoIncrement(true)->setComment("{$locality} ID");
             $table->addColumn('geoname_id', 'integer')->setUnsigned(true)->setNotNull(false)->setComment('GeoNames.org ID');
             $table->addColumn('country_id', 'integer')->setUnsigned(true)->setNotNull(true)->setComment('Country (=> ' . CountryTableDefinition::NAME . '.id)');
             $table->addColumn('name_utf8', 'string')->setLength(200)->setNotNull(true)->setComment("Name (UTF-8 encoding)");
             $table->addColumn('name_ascii', 'string')->setLength(200)->setNotNull(false)->setComment("Name (ASCII encoding)");
             $table->addColumn('latitude', 'decimal')->setPrecision(9)->setScale(6)->setNotNull(false)->setComment("Latitude coordinate");
             $table->addColumn('longitude', 'decimal')->setPrecision(9)->setScale(6)->setNotNull(false)->setComment("Longitude coordinate");
             $table->addColumn('timezone_id', 'integer')->setUnsigned(true)->setNotNull(false)->setComment("Timezone");
             $table->addColumn('creation_date', 'datetime')->setNotNull(true)->setComment("Database creation date");
             $table->addColumn('modification_date', 'datetime')->setNotNull(false)->setComment("Database modification date");
             // Primary key
             $table->setPrimaryKey(['id'], "PK_Geo{$locality}_id");
             // Unique Keys
             $table->addUniqueIndex(['geoname_id'], 'UK_Geo{$locality}_geoname');
             // Foriegn keys
             $table->addNamedForeignKeyConstraint("FK_Geo{$locality}_country", CountryTableDefinition::NAME, ['country_id'], ['id']);
             $table->addNamedForeignKeyConstraint("FK_Geo{$locality}_timezone", TimezoneTableDefinition::NAME, ['timezone_id'], ['id']);
     }
 }
开发者ID:28karonte,项目名称:JJsGeonamesBundle,代码行数:31,代码来源:LocalityTableDefinition.php

示例2: define

 /**
  * Defines the table at the specified version
  * 
  * @param Table  $table   Table
  * @param string $version Version
  */
 public function define(Table $table, $version)
 {
     switch (true) {
         // Version 0.1.0
         case version_compare($version, "0.1.0", '>='):
             $table->addColumn('id', 'integer')->setUnsigned(true)->setNotNull(true)->setAutoIncrement(true)->setComment('Timezone ID (local db)');
             $table->addColumn('country_id', 'integer')->setUnsigned(true)->setNotNull(true)->setComment('Country (=> ' . CountryTableDefinition::NAME . '.id)');
             $table->addColumn('code', 'string')->setLength(50)->setNotNull(false)->setComment("Timezone code");
             // Primary key
             $table->setPrimaryKey(['id'], 'PK_GeoTimezone_id');
             // Foriegn keys
             $table->addNamedForeignKeyConstraint('FK_GeoTimezone_country', CountryTableDefinition::NAME, ['country_id'], ['id']);
             // Unique Keys
             $table->addUniqueIndex(['code'], 'UK_GeoTimezone_code');
     }
 }
开发者ID:28karonte,项目名称:JJsGeonamesBundle,代码行数:22,代码来源:TimezoneTableDefinition.php

示例3: testCompareForeignKeyBasedOnPropertiesNotName

 public function testCompareForeignKeyBasedOnPropertiesNotName()
 {
     $tableA = new Table("foo");
     $tableA->addColumn('id', 'integer');
     $tableA->addNamedForeignKeyConstraint('foo_constraint', 'bar', array('id'), array('id'));
     $tableB = new Table("foo");
     $tableB->addColumn('ID', 'integer');
     $tableB->addNamedForeignKeyConstraint('bar_constraint', 'bar', array('id'), array('id'));
     $c = new Comparator();
     $tableDiff = $c->diffTable($tableA, $tableB);
     $this->assertFalse($tableDiff);
 }
开发者ID:llinder,项目名称:FrameworkBenchmarks,代码行数:12,代码来源:ComparatorTest.php


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