| @@ 999-1013 (lines=15) @@ | ||
| 996 | * @param string $tableName Table name |
|
| 997 | * @return string |
|
| 998 | */ |
|
| 999 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) |
|
| 1000 | { |
|
| 1001 | $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); |
|
| 1002 | ||
| 1003 | $def = ' CONSTRAINT "' . $constraintName . '" FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; |
|
| 1004 | $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; |
|
| 1005 | if ($foreignKey->getOnDelete()) { |
|
| 1006 | $def .= " ON DELETE {$foreignKey->getOnDelete()}"; |
|
| 1007 | } |
|
| 1008 | if ($foreignKey->getOnUpdate()) { |
|
| 1009 | $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; |
|
| 1010 | } |
|
| 1011 | ||
| 1012 | return $def; |
|
| 1013 | } |
|
| 1014 | ||
| 1015 | /** |
|
| 1016 | * {@inheritdoc} |
|
| @@ 1088-1102 (lines=15) @@ | ||
| 1085 | * @param \Phinx\Db\Table\ForeignKey $foreignKey |
|
| 1086 | * @return string |
|
| 1087 | */ |
|
| 1088 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) |
|
| 1089 | { |
|
| 1090 | $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); |
|
| 1091 | $def = ' CONSTRAINT ' . $this->quoteColumnName($constraintName); |
|
| 1092 | $def .= ' FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; |
|
| 1093 | $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; |
|
| 1094 | if ($foreignKey->getOnDelete()) { |
|
| 1095 | $def .= " ON DELETE {$foreignKey->getOnDelete()}"; |
|
| 1096 | } |
|
| 1097 | if ($foreignKey->getOnUpdate()) { |
|
| 1098 | $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; |
|
| 1099 | } |
|
| 1100 | ||
| 1101 | return $def; |
|
| 1102 | } |
|
| 1103 | ||
| 1104 | /** |
|
| 1105 | * {@inheritdoc} |
|