@@ 1071-1085 (lines=15) @@ | ||
1068 | * @param \Phinx\Db\Table\ForeignKey $foreignKey |
|
1069 | * @return string |
|
1070 | */ |
|
1071 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) |
|
1072 | { |
|
1073 | $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); |
|
1074 | $def = ' CONSTRAINT ' . $this->quoteColumnName($constraintName); |
|
1075 | $def .= ' FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; |
|
1076 | $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; |
|
1077 | if ($foreignKey->getOnDelete()) { |
|
1078 | $def .= " ON DELETE {$foreignKey->getOnDelete()}"; |
|
1079 | } |
|
1080 | if ($foreignKey->getOnUpdate()) { |
|
1081 | $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; |
|
1082 | } |
|
1083 | ||
1084 | return $def; |
|
1085 | } |
|
1086 | ||
1087 | /** |
|
1088 | * {@inheritdoc} |
@@ 1059-1073 (lines=15) @@ | ||
1056 | * @param string $tableName Table name |
|
1057 | * @return string |
|
1058 | */ |
|
1059 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) |
|
1060 | { |
|
1061 | $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); |
|
1062 | ||
1063 | $def = ' CONSTRAINT "' . $constraintName . '" FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; |
|
1064 | $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; |
|
1065 | if ($foreignKey->getOnDelete()) { |
|
1066 | $def .= " ON DELETE {$foreignKey->getOnDelete()}"; |
|
1067 | } |
|
1068 | if ($foreignKey->getOnUpdate()) { |
|
1069 | $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; |
|
1070 | } |
|
1071 | ||
1072 | return $def; |
|
1073 | } |
|
1074 | ||
1075 | /** |
|
1076 | * {@inheritdoc} |