Permalink
Browse files

Unindent, and remove unnecessary getDataSource() call.

Also, objects should be CamelCase.
  • Loading branch information...
1 parent b35c967 commit 7f570f33e487098e1955812440d465c6aabcab8f @bar bar committed Nov 12, 2013
Showing with 26 additions and 14 deletions.
  1. +26 −14 lib/Cake/Model/Datasource/DboSource.php
@@ -2048,27 +2048,39 @@ protected function _matchRecords(Model $model, $conditions = null) {
/**
* Returns an array of SQL JOIN fragments from a model's associations
*
- * @param Model $model
+ * @param Model $Model
* @return array
*/
- protected function _getJoins(Model $model) {
+ protected function _getJoins(Model $Model) {
$join = array();
- $joins = array_merge($model->getAssociated('hasOne'), $model->getAssociated('belongsTo'));
+ $joins = array_merge($Model->getAssociated('hasOne'), $Model->getAssociated('belongsTo'));
foreach ($joins as $assoc) {
- if (isset($model->{$assoc}) && $model->useDbConfig == $model->{$assoc}->useDbConfig && $model->{$assoc}->getDataSource()) {
- $assocData = $model->getAssociated($assoc);
- $join[] = $this->buildJoinStatement(array(
- 'table' => $model->{$assoc},
- 'alias' => $assoc,
- 'type' => isset($assocData['type']) ? $assocData['type'] : 'LEFT',
- 'conditions' => trim($this->conditions(
- $this->_mergeConditions($assocData['conditions'], $this->getConstraint($assocData['association'], $model, $model->{$assoc}, $assoc, $assocData)),
- true, false, $model
- ))
- ));
+ if (!isset($Model->{$assoc})) {
+ continue;
}
+
+ $LinkModel = $Model->{$assoc};
+
+ if ($Model->useDbConfig !== $LinkModel->useDbConfig) {
+ continue;
+ }
+
+ $assocData = $Model->getAssociated($assoc);
+
+ $join[] = $this->buildJoinStatement(array(
+ 'table' => $LinkModel,
+ 'alias' => $assoc,
+ 'type' => isset($assocData['type']) ? $assocData['type'] : 'LEFT',
+ 'conditions' => trim($this->conditions(
+ $this->_mergeConditions($assocData['conditions'], $this->getConstraint($assocData['association'], $Model, $LinkModel, $assoc, $assocData)),
+ true,
+ false,
+ $Model
+ ))
+ ));
}
+
return $join;
}

0 comments on commit 7f570f3

Please sign in to comment.