Browse files

Draft fix for #1271.

  • Loading branch information...
1 parent 446bb67 commit cf1e63953feab2fb2edc7fe9ee700c5c680bf074 @resurtm committed Nov 11, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 framework/db/ar/CActiveFinder.php
View
8 framework/db/ar/CActiveFinder.php
@@ -249,7 +249,7 @@ private function buildJoinTree($parent,$with,$options=null)
return new CStatElement($this,$relation,$parent);
else
{
- if(isset($parent->children[$with]))
+ if(isset($parent->children[$with]) && empty($relation->alias))
{
$element=$parent->children[$with];
$element->relation=$relation;
@@ -258,7 +258,11 @@ private function buildJoinTree($parent,$with,$options=null)
$element=new CJoinElement($this,$relation,$parent,++$this->_joinCount);
if(!empty($relation->through))
{
- $slave=$this->buildJoinTree($parent,$relation->through,array('select'=>false));
+ if(is_array($relation->through))
+ $slave=$this->buildJoinTree($parent,key($relation->through),
+ array('select'=>false,'alias'=>reset($relation->through)));
+ else
+ $slave=$this->buildJoinTree($parent,$relation->through,array('select'=>false));
$slave->master=$element;
$element->slave=$slave;
}

0 comments on commit cf1e639

Please sign in to comment.