Fixed problem with relationships that are defined soley on the 'conditions' part of the association, and not on 'foreignKey' (which is allowed to be 'false').

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@80 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-10 02:31:49 +00:00
parent ebc4a42ae9
commit 3dcd83229b

View File

@@ -177,7 +177,8 @@ class LinkableBehavior extends ModelBehavior {
$options['alias'] = $linkAlias;
$options['table'] = $Link->getDataSource()->fullTableName($Link);
$options['conditions'][] = "{$referenceLink} = {$referenceKey}";
} else {
}
elseif (isset($association['foreignKey']) && $association['foreignKey']) {
$foreignKey = $primaryModel->escapeField($association['foreignKey']);
$primaryKey = $foreignModel->escapeField($foreignModel->primaryKey);
@@ -188,6 +189,10 @@ class LinkableBehavior extends ModelBehavior {
else
$options['conditions'][] = "{$foreignKey} = {$primaryKey}";
}
else {
// No Foreign Key... nothing we can do.
$options['conditions'] = array();
}
// The user may have specified conditions directly in the model
// for this join. Make sure to adhere to those conditions.