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.