| @@ 1085-1099 (lines=15) @@ | ||
| 1082 | * @param \Phinx\Db\Table\ForeignKey $foreignKey |
|
| 1083 | * @return string |
|
| 1084 | */ |
|
| 1085 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) |
|
| 1086 | { |
|
| 1087 | $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); |
|
| 1088 | $def = ' CONSTRAINT ' . $this->quoteColumnName($constraintName); |
|
| 1089 | $def .= ' FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; |
|
| 1090 | $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; |
|
| 1091 | if ($foreignKey->getOnDelete()) { |
|
| 1092 | $def .= " ON DELETE {$foreignKey->getOnDelete()}"; |
|
| 1093 | } |
|
| 1094 | if ($foreignKey->getOnUpdate()) { |
|
| 1095 | $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; |
|
| 1096 | } |
|
| 1097 | ||
| 1098 | return $def; |
|
| 1099 | } |
|
| 1100 | ||
| 1101 | /** |
|
| 1102 | * {@inheritdoc} |
|
| @@ 1018-1032 (lines=15) @@ | ||
| 1015 | * @param string $tableName Table name |
|
| 1016 | * @return string |
|
| 1017 | */ |
|
| 1018 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) |
|
| 1019 | { |
|
| 1020 | $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); |
|
| 1021 | ||
| 1022 | $def = ' CONSTRAINT "' . $constraintName . '" FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; |
|
| 1023 | $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; |
|
| 1024 | if ($foreignKey->getOnDelete()) { |
|
| 1025 | $def .= " ON DELETE {$foreignKey->getOnDelete()}"; |
|
| 1026 | } |
|
| 1027 | if ($foreignKey->getOnUpdate()) { |
|
| 1028 | $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; |
|
| 1029 | } |
|
| 1030 | ||
| 1031 | return $def; |
|
| 1032 | } |
|
| 1033 | ||
| 1034 | /** |
|
| 1035 | * {@inheritdoc} |
|