From 3dcd83229b4b68c82b3b23dae29d190a6ba93f7a Mon Sep 17 00:00:00 2001 From: abijah Date: Wed, 10 Jun 2009 02:31:49 +0000 Subject: [PATCH] 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 --- models/behaviors/linkable.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/models/behaviors/linkable.php b/models/behaviors/linkable.php index 388456f..c530ea5 100644 --- a/models/behaviors/linkable.php +++ b/models/behaviors/linkable.php @@ -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.