| @@ 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} |
|
| @@ 1110-1124 (lines=15) @@ | ||
| 1107 | * @param \Phinx\Db\Table\ForeignKey $foreignKey |
|
| 1108 | * @return string |
|
| 1109 | */ |
|
| 1110 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) |
|
| 1111 | { |
|
| 1112 | $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); |
|
| 1113 | $def = ' CONSTRAINT ' . $this->quoteColumnName($constraintName); |
|
| 1114 | $def .= ' FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; |
|
| 1115 | $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; |
|
| 1116 | if ($foreignKey->getOnDelete()) { |
|
| 1117 | $def .= " ON DELETE {$foreignKey->getOnDelete()}"; |
|
| 1118 | } |
|
| 1119 | if ($foreignKey->getOnUpdate()) { |
|
| 1120 | $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; |
|
| 1121 | } |
|
| 1122 | ||
| 1123 | return $def; |
|
| 1124 | } |
|
| 1125 | ||
| 1126 | /** |
|
| 1127 | * {@inheritdoc} |
|