Changeset 4493 for branches/0.11/lib/Doctrine/Query/JoinCondition.php
- Timestamp:
- 06/08/08 15:50:10 (21 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/0.11/lib/Doctrine/Query/JoinCondition.php
r4366 r4493 40 40 41 41 if (count($e) > 2) { 42 $expr = new Doctrine_Expression($e[0], $this->query->getConnection()); 43 $e[0] = $expr->getSql(); 44 45 $operator = $e[1]; 46 47 $expr = new Doctrine_Expression($e[2], $this->query->getConnection()); 48 $e[2] = $expr->getSql(); 49 50 // We need to check for agg functions here 51 $hasLeftAggExpression = preg_match('/(.*)\(([^\)]*)\)([\)]*)/', $e[0], $leftMatches); 52 53 if ($hasLeftAggExpression) { 54 $e[0] = $leftMatches[2]; 55 } 56 57 $hasRightAggExpression = preg_match('/(.*)\(([^\)]*)\)([\)]*)/', $e[2], $rightMatches); 58 59 if ($hasRightAggExpression) { 60 $e[2] = $rightMatches[2]; 61 } 62 42 63 $a = explode('.', $e[0]); 43 64 $field = array_pop($a); 44 65 $reference = implode('.', $a); 45 $operator = $e[1];46 66 $value = $e[2]; 47 67 … … 104 124 } 105 125 default: 106 $condition = $alias . '.' . $field . ' ' 107 . $operator . ' ' . $value; 126 $leftExpr = (($hasLeftAggExpression) ? $leftMatches[1] . '(' : '') 127 . $alias . '.' . $field 128 . (($hasLeftAggExpression) ? $leftMatches[3] . ')' : '') ; 129 130 $rightExpr = (($hasRightAggExpression) ? $rightMatches[1] . '(' : '') 131 . $value 132 . (($hasRightAggExpression) ? $rightMatches[3] . ')' : '') ; 133 134 $condition = $leftExpr . ' ' . $operator . ' ' . $rightExpr; 108 135 } 109 136 110 137 } 138 111 139 return $condition; 112 140 }