Beispiel #1
0
 /**
  * Checks whether the provided foreign key represents the same definition as this foreign key
  * @return boolean True if the 2 are the same, false otherwise
  */
 public function equals(ForeignKey $foreignKey)
 {
     if ($this->name != $foreignKey->getName()) {
         return false;
     }
     if ($this->fieldName != $foreignKey->getFieldName()) {
         return false;
     }
     if ($this->referenceTableName != $foreignKey->getReferenceTableName()) {
         return false;
     }
     if ($this->referenceFieldName != $foreignKey->getReferenceFieldName()) {
         return false;
     }
     return true;
 }
Beispiel #2
0
 /**
  * Adds a foreign key to the table
  * @param ForeignKey $foreignKey Definition of the foreign key to add
  * @throws zibo\library\database\exception\DatabaseException when the index is already set to this table
  */
 public function setForeignKey(ForeignKey $foreignKey)
 {
     $fieldName = $foreignKey->getFieldName();
     if (!$this->hasField($fieldName)) {
         throw new DatabaseException('Could not add the foreign key: The field is not set in this table');
     }
     $this->foreignKeys[$fieldName] = $foreignKey;
 }