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


PHP Schema\ForeignKeyConstraint類代碼示例

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


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

示例1: acceptForeignKey

 /**
  * {@inheritdoc}
  */
 public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
 {
     if (strlen($fkConstraint->getName()) == 0) {
         throw SchemaException::namedForeignKeyRequired($localTable, $fkConstraint);
     }
     $this->constraints->attach($fkConstraint, $localTable);
 }
開發者ID:alvarobfdev,項目名稱:applog,代碼行數:10,代碼來源:DropSchemaSqlCollector.php

示例2: testIntersectsIndexColumns

 /**
  * @group DBAL-1062
  *
  * @dataProvider getIntersectsIndexColumnsData
  */
 public function testIntersectsIndexColumns(array $indexColumns, $expectedResult)
 {
     $foreignKey = new ForeignKeyConstraint(array('foo', 'bar'), 'foreign_table', array('fk_foo', 'fk_bar'));
     $index = $this->getMockBuilder('Doctrine\\DBAL\\Schema\\Index')->disableOriginalConstructor()->getMock();
     $index->expects($this->once())->method('getColumns')->will($this->returnValue($indexColumns));
     $this->assertSame($expectedResult, $foreignKey->intersectsIndexColumns($index));
 }
開發者ID:selimcr,項目名稱:servigases,代碼行數:12,代碼來源:ForeignKeyConstraintTest.php

示例3: acceptForeignKey

 /**
  * @param Table $localTable
  * @param ForeignKeyConstraint $fkConstraint
  */
 public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
 {
     if (strlen($fkConstraint->getName()) == 0) {
         throw SchemaException::namedForeignKeyRequired($localTable, $fkConstraint);
     }
     $this->_constraints[] = $this->_platform->getDropForeignKeySQL($fkConstraint->getQuotedName($this->_platform), $localTable->getQuotedName($this->_platform));
 }
開發者ID:MarS2806,項目名稱:Zend-Framework--Doctrine-ORM--PHPUnit--Ant--Jenkins-CI--TDD-,代碼行數:11,代碼來源:DropSchemaSqlCollector.php

示例4: acceptForeignKey

 /**
  * @param Table $localTable
  * @param ForeignKeyConstraint $fkConstraint
  */
 public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
 {
     if ($this->_addExplicitIndexForForeignKey) {
         $columns = $fkConstraint->getColumns();
         if ($localTable->columnsAreIndexed($columns)) {
             return;
         }
         $localTable->addIndex($columns);
     }
 }
開發者ID:jacques-sounvi,項目名稱:addressbook,代碼行數:14,代碼來源:FixSchema.php

示例5: acceptForeignKey

 /**
  * {@inheritdoc}
  */
 public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
 {
     // The table may already be deleted in a previous
     // RemoveNamespacedAssets#acceptTable call. Removing Foreign keys that
     // point to nowhere.
     if (!$this->schema->hasTable($fkConstraint->getForeignTableName())) {
         $localTable->removeForeignKey($fkConstraint->getName());
         return;
     }
     $foreignTable = $this->schema->getTable($fkConstraint->getForeignTableName());
     if (!$foreignTable->isInDefaultNamespace($this->schema->getName())) {
         $localTable->removeForeignKey($fkConstraint->getName());
     }
 }
開發者ID:Kevin-ZK,項目名稱:vaneDisk,代碼行數:17,代碼來源:RemoveNamespacedAssets.php

示例6: _addForeignKeyConstraint

 /**
  * @param ForeignKeyConstraint $constraint
  */
 protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint)
 {
     $constraint->setLocalTable($this);
     if (strlen($constraint->getName())) {
         $name = $constraint->getName();
     } else {
         $name = $this->_generateIdentifierName(array_merge((array) $this->getName(), $constraint->getLocalColumns()), "fk", $this->_getMaxIdentifierLength());
     }
     $name = strtolower($name);
     $this->_fkConstraints[$name] = $constraint;
 }
開發者ID:andreia,項目名稱:doctrine,代碼行數:14,代碼來源:Table.php

示例7: diffForeignKey

 /**
  * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $key1
  * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $key2
  *
  * @return boolean
  */
 public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2)
 {
     if (array_map('strtolower', $key1->getUnquotedLocalColumns()) != array_map('strtolower', $key2->getUnquotedLocalColumns())) {
         return true;
     }
     if (array_map('strtolower', $key1->getUnquotedForeignColumns()) != array_map('strtolower', $key2->getUnquotedForeignColumns())) {
         return true;
     }
     if ($key1->getUnqualifiedForeignTableName() !== $key2->getUnqualifiedForeignTableName()) {
         return true;
     }
     if ($key1->onUpdate() != $key2->onUpdate()) {
         return true;
     }
     if ($key1->onDelete() != $key2->onDelete()) {
         return true;
     }
     return false;
 }
開發者ID:kirkbauer2,項目名稱:kirkxc,代碼行數:25,代碼來源:Comparator.php

示例8: getGenerateConstraintForeignKeySql

 public function getGenerateConstraintForeignKeySql(ForeignKeyConstraint $fk)
 {
     $quotedForeignTable = $fk->getQuotedForeignTableName($this->_platform);
     return 'ALTER TABLE test ADD CONSTRAINT FOREIGN KEY (fk_name) ' . 'REFERENCES ' . $quotedForeignTable . ' (id) CONSTRAINT constraint_fk';
 }
開發者ID:josemalonsom,項目名稱:ifx4dd,代碼行數:5,代碼來源:InformixPlatformTest.php

示例9: getAdvancedForeignKeyOptionsSQL

 /**
  * {@inheritDoc}
  */
 public function getAdvancedForeignKeyOptionsSQL(\Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey)
 {
     $query = '';
     if ($foreignKey->hasOption('match')) {
         $query .= ' MATCH ' . $foreignKey->getOption('match');
     }
     $query .= parent::getAdvancedForeignKeyOptionsSQL($foreignKey);
     return $query;
 }
開發者ID:tamboer,項目名稱:LaravelOctober,代碼行數:12,代碼來源:MySqlPlatform.php

示例10: getAdvancedForeignKeyOptionsSQL

 /**
  * {@inheritDoc}
  */
 public function getAdvancedForeignKeyOptionsSQL(\Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey)
 {
     $query = '';
     if ($foreignKey->hasOption('match')) {
         $query .= ' MATCH ' . $foreignKey->getOption('match');
     }
     $query .= parent::getAdvancedForeignKeyOptionsSQL($foreignKey);
     if ($foreignKey->hasOption('deferrable') && $foreignKey->getOption('deferrable') !== false) {
         $query .= ' DEFERRABLE';
     } else {
         $query .= ' NOT DEFERRABLE';
     }
     if ($foreignKey->hasOption('feferred') && $foreignKey->getOption('feferred') !== false || $foreignKey->hasOption('deferred') && $foreignKey->getOption('deferred') !== false) {
         $query .= ' INITIALLY DEFERRED';
     } else {
         $query .= ' INITIALLY IMMEDIATE';
     }
     return $query;
 }
開發者ID:cuppyzh,項目名稱:go_laundry,代碼行數:22,代碼來源:PostgreSqlPlatform.php

示例11: getForeignKeyBaseDeclarationSQL

 /**
  * Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
  * of a field declaration to be used in statements like CREATE TABLE.
  *
  * @param ForeignKeyConstraint $foreignKey
  * @return string
  */
 public function getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey)
 {
     $sql = '';
     if (strlen($foreignKey->getName())) {
         $sql .= 'CONSTRAINT ' . $foreignKey->getQuotedName($this) . ' ';
     }
     $sql .= 'FOREIGN KEY (';
     if (count($foreignKey->getLocalColumns()) == 0) {
         throw new \InvalidArgumentException("Incomplete definition. 'local' required.");
     }
     if (count($foreignKey->getForeignColumns()) == 0) {
         throw new \InvalidArgumentException("Incomplete definition. 'foreign' required.");
     }
     if (strlen($foreignKey->getForeignTableName()) == 0) {
         throw new \InvalidArgumentException("Incomplete definition. 'foreignTable' required.");
     }
     $sql .= implode(', ', $foreignKey->getLocalColumns()) . ') REFERENCES ' . $foreignKey->getForeignTableName() . ' (' . implode(', ', $foreignKey->getForeignColumns()) . ')';
     return $sql;
 }
開發者ID:pollux1er,項目名稱:dlawebdev2,代碼行數:26,代碼來源:AbstractPlatform.php

示例12: _addForeignKeyConstraint

 /**
  * @param ForeignKeyConstraint $constraint
  *
  * @return void
  */
 protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint)
 {
     $constraint->setLocalTable($this);
     if (strlen($constraint->getName())) {
         $name = $constraint->getName();
     } else {
         $name = $this->_generateIdentifierName(array_merge((array) $this->getName(), $constraint->getLocalColumns()), "fk", $this->_getMaxIdentifierLength());
     }
     $name = $this->normalizeIdentifier($name);
     $this->_fkConstraints[$name] = $constraint;
     // add an explicit index on the foreign key columns. If there is already an index that fulfils this requirements drop the request.
     // In the case of __construct calling this method during hydration from schema-details all the explicitly added indexes
     // lead to duplicates. This creates computation overhead in this case, however no duplicate indexes are ever added (based on columns).
     $indexName = $this->_generateIdentifierName(array_merge(array($this->getName()), $constraint->getColumns()), "idx", $this->_getMaxIdentifierLength());
     $indexCandidate = $this->_createIndex($constraint->getColumns(), $indexName, false, false);
     foreach ($this->_indexes as $existingIndex) {
         if ($indexCandidate->isFullfilledBy($existingIndex)) {
             return;
         }
     }
     $this->_addIndex($indexCandidate);
     $this->implicitIndexes[$this->normalizeIdentifier($indexName)] = $indexCandidate;
 }
開發者ID:BusinessCookies,項目名稱:CoffeeMachineProject,代碼行數:28,代碼來源:Table.php

示例13: getAdvancedForeignKeyOptionsSQL

 /**
  * Returns the FOREIGN KEY query section dealing with non-standard options
  * as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
  *
  * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey The foreign key definition.
  *
  * @return string
  */
 public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey)
 {
     $query = '';
     if ($this->supportsForeignKeyOnUpdate() && $foreignKey->hasOption('onUpdate')) {
         $query .= ' ON UPDATE ' . $this->getForeignKeyReferentialActionSQL($foreignKey->getOption('onUpdate'));
     }
     if ($foreignKey->hasOption('onDelete')) {
         $query .= ' ON DELETE ' . $this->getForeignKeyReferentialActionSQL($foreignKey->getOption('onDelete'));
     }
     return $query;
 }
開發者ID:BozzaCoon,項目名稱:SPHERE-Framework,代碼行數:19,代碼來源:AbstractPlatform.php

示例14: createForeignKeyReplacement

 /**
  * Creates a foreign index replacement, which has quoted column names.
  *
  * @param ForeignKeyConstraint $fk
  *
  * @return ForeignKeyConstraint
  */
 private function createForeignKeyReplacement(ForeignKeyConstraint $fk)
 {
     return new ForeignKeyConstraint($this->quoteIdentifiers($fk->getLocalColumns()), $this->platform->quoteIdentifier($fk->getForeignTableName()), $this->quoteIdentifiers($fk->getForeignColumns()), $this->platform->quoteIdentifier($fk->getName()), $fk->getOptions());
 }
開發者ID:digilist,項目名稱:snakedumper,代碼行數:11,代碼來源:IdentifierQuoter.php

示例15: getCreateForeignKeySQL

 /**
  * @param ForeignKeyConstraint $foreignKey
  * @param Table|string         $table
  *
  * @return string
  */
 public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table)
 {
     $columns = $foreignKey->getColumns();
     $column = reset($columns);
     $column = $table->getColumn($column);
     $sql = array();
     if ($column->hasCustomSchemaOption('definedIn') and $column->getCustomSchemaOption('definedIn') === 'link') {
         $sql = $this->_getCreateColumnSQL($foreignKey->getLocalTableName(), $column->getName(), $column->toArray());
     }
     return $sql;
 }
開發者ID:mihai-stancu,項目名稱:orientdb-orm,代碼行數:17,代碼來源:OrientDBPlatform.php


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