| @@ 1049-1072 (lines=24) @@ | ||
| 1046 | * @param \Phinx\Db\Table\ForeignKey $foreignKey |
|
| 1047 | * @return string |
|
| 1048 | */ |
|
| 1049 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey) |
|
| 1050 | { |
|
| 1051 | $def = ''; |
|
| 1052 | if ($foreignKey->getConstraint()) { |
|
| 1053 | $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint()); |
|
| 1054 | } |
|
| 1055 | $columnNames = []; |
|
| 1056 | foreach ($foreignKey->getColumns() as $column) { |
|
| 1057 | $columnNames[] = $this->quoteColumnName($column); |
|
| 1058 | } |
|
| 1059 | $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')'; |
|
| 1060 | $refColumnNames = []; |
|
| 1061 | foreach ($foreignKey->getReferencedColumns() as $column) { |
|
| 1062 | $refColumnNames[] = $this->quoteColumnName($column); |
|
| 1063 | } |
|
| 1064 | $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')'; |
|
| 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 | /** |
|
| @@ 1041-1065 (lines=25) @@ | ||
| 1038 | * @param \Phinx\Db\Table\ForeignKey $foreignKey |
|
| 1039 | * @return string |
|
| 1040 | */ |
|
| 1041 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey) |
|
| 1042 | { |
|
| 1043 | $def = ''; |
|
| 1044 | if ($foreignKey->getConstraint()) { |
|
| 1045 | $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint()); |
|
| 1046 | } else { |
|
| 1047 | $columnNames = []; |
|
| 1048 | foreach ($foreignKey->getColumns() as $column) { |
|
| 1049 | $columnNames[] = $this->quoteColumnName($column); |
|
| 1050 | } |
|
| 1051 | $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')'; |
|
| 1052 | $refColumnNames = []; |
|
| 1053 | foreach ($foreignKey->getReferencedColumns() as $column) { |
|
| 1054 | $refColumnNames[] = $this->quoteColumnName($column); |
|
| 1055 | } |
|
| 1056 | $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')'; |
|
| 1057 | if ($foreignKey->getOnDelete()) { |
|
| 1058 | $def .= ' ON DELETE ' . $foreignKey->getOnDelete(); |
|
| 1059 | } |
|
| 1060 | if ($foreignKey->getOnUpdate()) { |
|
| 1061 | $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate(); |
|
| 1062 | } |
|
| 1063 | } |
|
| 1064 | ||
| 1065 | return $def; |
|
| 1066 | } |
|
| 1067 | } |
|
| 1068 | ||