diff --git a/lib/Doctrine/Export.php b/lib/Doctrine/Export.php index e52dcef1d..fc2ec97bc 100644 --- a/lib/Doctrine/Export.php +++ b/lib/Doctrine/Export.php @@ -223,10 +223,7 @@ class Doctrine_Export extends Doctrine_Connection_Module foreach ((array) $options['foreignKeys'] as $k => $definition) { if (is_array($definition)) { - if ( ! isset($definition['table'])) { - $definition['table'] = $name; - } - $sql[] = $this->createForeignKeySql($definition['table'], $definition); + $sql[] = $this->createForeignKeySql($name, $definition); } } } @@ -868,6 +865,7 @@ class Doctrine_Export extends Doctrine_Connection_Module if ( ! is_array($definition['foreign'])) { $definition['foreign'] = array($definition['foreign']); } + $sql .= implode(', ', array_map(array($this->conn, 'quoteIdentifier'), $definition['local'])) . ') REFERENCES ' . $definition['foreignTable'] . '(' @@ -1007,7 +1005,7 @@ class Doctrine_Export extends Doctrine_Connection_Module } else { $sql[] = $query; } - + if (isset($data['options']['foreignKeys']) && is_array($data['options']['foreignKeys'])) { $fks[$table->getTableName()] = $data['options']['foreignKeys']; } diff --git a/lib/Doctrine/Export/Mysql.php b/lib/Doctrine/Export/Mysql.php index fc9ca910b..cbd1f1020 100644 --- a/lib/Doctrine/Export/Mysql.php +++ b/lib/Doctrine/Export/Mysql.php @@ -166,10 +166,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export foreach ((array) $options['foreignKeys'] as $k => $definition) { if (is_array($definition)) { - if ( ! isset($definition['table'])) { - $definition['table'] = $name; - } - $sql[] = $this->createForeignKeySql($definition['table'], $definition); + $sql[] = $this->createForeignKeySql($name, $definition); } } } diff --git a/lib/Doctrine/Table.php b/lib/Doctrine/Table.php index 706822c7b..c661934d4 100644 --- a/lib/Doctrine/Table.php +++ b/lib/Doctrine/Table.php @@ -382,9 +382,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable $relation->hasConstraint()) { $def = array('local' => $relation->getLocal(), - 'table' => $relation->getTable()->getTableName(), 'foreign' => $this->getIdentifier(), - 'foreignTable' => $this->getTableName()); + 'foreignTable' => $relation->getTable()->getTableName()); if (($key = array_search($def, $options['foreignKeys'])) === false) { $options['foreignKeys'][] = $def; @@ -402,9 +401,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable $relation->getForeign() !== $relation->getTable()->getIdentifier()) { $def = array('local' => $relation->getLocal(), - 'table' => $relation->getTable()->getTableName(), 'foreign' => $this->getIdentifier(), - 'foreignTable' => $this->getTableName()); + 'foreignTable' => $relation->getTable()->getTableName()); if (($key = array_search($def, $options['foreignKeys'])) === false) { $options['foreignKeys'][] = $def;