Esempio n. 1
0
 /**
  * Add/Update foreign key constraint
  * @param \DB\SQL\MySQL\Constraint $constraint
  */
 public function addConstraint($constraint)
 {
     if ($constraint->isValid()) {
         $this->queries[] = "\n              ALTER TABLE " . $this->db->quotekey($this->name) . "\n                ADD CONSTRAINT " . $this->db->quotekey($constraint->getConstraintName()) . "\n                FOREIGN KEY (" . implode(', ', $constraint->getKeys()) . ")\n                REFERENCES " . $this->db->quotekey($constraint->getReferencedTable()) . " (" . implode(', ', $constraint->getReferencedCols()) . ")\n                  ON DELETE " . $constraint->getOnDelete() . "\n                  ON UPDATE " . $constraint->getOnUpdate() . ";";
     } else {
         trigger_error(sprintf(self::TEXT_ConstraintNotValid, 'table: ' . $this->name . ' constraintName: ' . $constraint->getConstraintName()));
     }
 }