| @@ 1061-1084 (lines=24) @@ | ||
| 1058 | * @param ForeignKey $foreignKey |
|
| 1059 | * @return string |
|
| 1060 | */ |
|
| 1061 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey) |
|
| 1062 | { |
|
| 1063 | $def = ''; |
|
| 1064 | if ($foreignKey->getConstraint()) { |
|
| 1065 | $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint()); |
|
| 1066 | } |
|
| 1067 | $columnNames = []; |
|
| 1068 | foreach ($foreignKey->getColumns() as $column) { |
|
| 1069 | $columnNames[] = $this->quoteColumnName($column); |
|
| 1070 | } |
|
| 1071 | $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')'; |
|
| 1072 | $refColumnNames = []; |
|
| 1073 | foreach ($foreignKey->getReferencedColumns() as $column) { |
|
| 1074 | $refColumnNames[] = $this->quoteColumnName($column); |
|
| 1075 | } |
|
| 1076 | $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')'; |
|
| 1077 | if ($foreignKey->getOnDelete()) { |
|
| 1078 | $def .= ' ON DELETE ' . $foreignKey->getOnDelete(); |
|
| 1079 | } |
|
| 1080 | if ($foreignKey->getOnUpdate()) { |
|
| 1081 | $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate(); |
|
| 1082 | } |
|
| 1083 | return $def; |
|
| 1084 | } |
|
| 1085 | ||
| 1086 | /** |
|
| 1087 | * Describes a database table. This is a MySQL adapter specific method. |
|
| @@ 1067-1091 (lines=25) @@ | ||
| 1064 | * @param ForeignKey $foreignKey |
|
| 1065 | * @return string |
|
| 1066 | */ |
|
| 1067 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey) |
|
| 1068 | { |
|
| 1069 | $def = ''; |
|
| 1070 | if ($foreignKey->getConstraint()) { |
|
| 1071 | $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint()); |
|
| 1072 | } else { |
|
| 1073 | $columnNames = []; |
|
| 1074 | foreach ($foreignKey->getColumns() as $column) { |
|
| 1075 | $columnNames[] = $this->quoteColumnName($column); |
|
| 1076 | } |
|
| 1077 | $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')'; |
|
| 1078 | $refColumnNames = []; |
|
| 1079 | foreach ($foreignKey->getReferencedColumns() as $column) { |
|
| 1080 | $refColumnNames[] = $this->quoteColumnName($column); |
|
| 1081 | } |
|
| 1082 | $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')'; |
|
| 1083 | if ($foreignKey->getOnDelete()) { |
|
| 1084 | $def .= ' ON DELETE ' . $foreignKey->getOnDelete(); |
|
| 1085 | } |
|
| 1086 | if ($foreignKey->getOnUpdate()) { |
|
| 1087 | $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate(); |
|
| 1088 | } |
|
| 1089 | } |
|
| 1090 | return $def; |
|
| 1091 | } |
|
| 1092 | } |
|
| 1093 | ||