Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
 /**
  * @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;
     // add an explicit index on the foreign key columns. If there is already an index that fullfils 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 compuation overhead in this case, however no duplicate indexes are ever added (based on columns).
     $this->addIndex($constraint->getColumns());
 }
 /**
  * @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;
 }