fixed ticket #571
This commit is contained in:
parent
ee9e79d09e
commit
175d3307c2
@ -969,38 +969,43 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
|||||||
$q .= $part;
|
$q .= $part;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// preserve LEFT JOINs only if needed
|
// preserve LEFT JOINs only if needed
|
||||||
|
// Check if it's JOIN, if not add a comma separator instead of space
|
||||||
|
if (!preg_match('/\bJOIN\b/i', $part) && !isset($this->_pendingJoinConditions[$k])) {
|
||||||
|
$q .= ', ' . $part;
|
||||||
|
} else {
|
||||||
|
if (substr($part, 0, 9) === 'LEFT JOIN') {
|
||||||
|
$e = explode(' ', $part);
|
||||||
|
|
||||||
if (substr($part, 0, 9) === 'LEFT JOIN') {
|
$aliases = array_merge($this->subqueryAliases,
|
||||||
$e = explode(' ', $part);
|
array_keys($this->_neededTables));
|
||||||
|
|
||||||
$aliases = array_merge($this->subqueryAliases,
|
if ( ! in_array($e[3], $aliases) &&
|
||||||
array_keys($this->_neededTables));
|
! in_array($e[2], $aliases) &&
|
||||||
|
|
||||||
if ( ! in_array($e[3], $aliases) &&
|
! empty($this->_pendingFields)) {
|
||||||
! in_array($e[2], $aliases) &&
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
! empty($this->_pendingFields)) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
if (isset($this->_pendingJoinConditions[$k])) {
|
||||||
|
$parser = new Doctrine_Query_JoinCondition($this);
|
||||||
|
|
||||||
if (isset($this->_pendingJoinConditions[$k])) {
|
if (strpos($part, ' ON ') !== false) {
|
||||||
$parser = new Doctrine_Query_JoinCondition($this);
|
$part .= ' AND ';
|
||||||
|
} else {
|
||||||
|
$part .= ' ON ';
|
||||||
|
}
|
||||||
|
$part .= $parser->parse($this->_pendingJoinConditions[$k]);
|
||||||
|
|
||||||
if (strpos($part, ' ON ') !== false) {
|
unset($this->_pendingJoinConditions[$k]);
|
||||||
$part .= ' AND ';
|
|
||||||
} else {
|
|
||||||
$part .= ' ON ';
|
|
||||||
}
|
}
|
||||||
$part .= $parser->parse($this->_pendingJoinConditions[$k]);
|
|
||||||
|
|
||||||
unset($this->_pendingJoinConditions[$k]);
|
$q .= ' ' . $part;
|
||||||
}
|
}
|
||||||
|
|
||||||
$q .= ' ' . $part;
|
|
||||||
|
|
||||||
$this->parts['from'][$k] = $part;
|
$this->parts['from'][$k] = $part;
|
||||||
}
|
}
|
||||||
return $q;
|
return $q;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user