@@ 1060-1074 (lines=15) @@ | ||
1057 | * @param string $tableName Table name |
|
1058 | * @return string |
|
1059 | */ |
|
1060 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) |
|
1061 | { |
|
1062 | $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); |
|
1063 | ||
1064 | $def = ' CONSTRAINT "' . $constraintName . '" FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; |
|
1065 | $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; |
|
1066 | if ($foreignKey->getOnDelete()) { |
|
1067 | $def .= " ON DELETE {$foreignKey->getOnDelete()}"; |
|
1068 | } |
|
1069 | if ($foreignKey->getOnUpdate()) { |
|
1070 | $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; |
|
1071 | } |
|
1072 | ||
1073 | return $def; |
|
1074 | } |
|
1075 | ||
1076 | /** |
|
1077 | * {@inheritdoc} |
@@ 1103-1117 (lines=15) @@ | ||
1100 | * @param \Phinx\Db\Table\ForeignKey $foreignKey |
|
1101 | * @return string |
|
1102 | */ |
|
1103 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) |
|
1104 | { |
|
1105 | $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); |
|
1106 | $def = ' CONSTRAINT ' . $this->quoteColumnName($constraintName); |
|
1107 | $def .= ' FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; |
|
1108 | $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; |
|
1109 | if ($foreignKey->getOnDelete()) { |
|
1110 | $def .= " ON DELETE {$foreignKey->getOnDelete()}"; |
|
1111 | } |
|
1112 | if ($foreignKey->getOnUpdate()) { |
|
1113 | $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; |
|
1114 | } |
|
1115 | ||
1116 | return $def; |
|
1117 | } |
|
1118 | ||
1119 | /** |
|
1120 | * {@inheritdoc} |