コード例 #1
0
ファイル: tablemodifier.php プロジェクト: tysongg/pathfinder
 /**
  * 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()));
     }
 }
コード例 #2
0
ファイル: tablemodifier.php プロジェクト: Quarky9/pathfinder
 /**
  * drop foreign key constraint
  * @param \DB\SQL\MySQL\Constraint $constraint
  */
 public function dropConstraint($constraint)
 {
     if ($constraint->isValid()) {
         $this->queries[] = "ALTER TABLE " . $this->db->quotekey($this->name) . "\n                                DROP FOREIGN KEY " . $this->db->quotekey($constraint->getConstraintName());
     } else {
         trigger_error(sprintf(self::TEXT_ConstraintNotValid, 'table: ' . $this->name . ' constraintName: ' . $constraint->getConstraintName()));
     }
 }