1
0
mirror of synced 2025-01-05 16:53:21 +03:00

fixed many-to-many column guessing

This commit is contained in:
zYne 2007-06-09 21:54:08 +00:00
parent 115cadb081
commit ca775fdc99

View File

@ -191,6 +191,23 @@ class Doctrine_Relation_Parser
$def['table'] = $conn->getTable($def['class']); $def['table'] = $conn->getTable($def['class']);
$def['refTable'] = $conn->getTable($def['refClass']); $def['refTable'] = $conn->getTable($def['refClass']);
$id = $def['refTable']->getIdentifier();
if (count($id) > 1) {
if ( ! isset($def['foreign'])) {
// foreign key not set
// try to guess the foreign key
$def['foreign'] = ($def['local'] === $id[0]) ? $id[1] : $id[0];
}
if ( ! isset($def['local'])) {
// foreign key not set
// try to guess the foreign key
$def['local'] = ($def['foreign'] === $id[0]) ? $id[1] : $id[0];
}
} else {
if ( ! isset($def['foreign'])) { if ( ! isset($def['foreign'])) {
// foreign key not set // foreign key not set
// try to guess the foreign key // try to guess the foreign key
@ -206,7 +223,7 @@ class Doctrine_Relation_Parser
$def['local'] = $columns; $def['local'] = $columns;
} }
}
return $def; return $def;
} }
/** /**