@@ 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} |
@@ 1027-1041 (lines=15) @@ | ||
1024 | * @param string $tableName Table name |
|
1025 | * @return string |
|
1026 | */ |
|
1027 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) |
|
1028 | { |
|
1029 | $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); |
|
1030 | ||
1031 | $def = ' CONSTRAINT "' . $constraintName . '" FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; |
|
1032 | $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; |
|
1033 | if ($foreignKey->getOnDelete()) { |
|
1034 | $def .= " ON DELETE {$foreignKey->getOnDelete()}"; |
|
1035 | } |
|
1036 | if ($foreignKey->getOnUpdate()) { |
|
1037 | $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; |
|
1038 | } |
|
1039 | ||
1040 | return $def; |
|
1041 | } |
|
1042 | ||
1043 | /** |
|
1044 | * {@inheritdoc} |