yiisoft/yii — pull request #2049 by Yiivgeny (2013-01-28 13:20:15+00:00)
Title: CStatElement with join bugfix

Model stat-relation defined with ambigous fields:
```php
public function relations() {
return array(
'someRelation' => array(
self::STAT,
'SomeModel',
'primary_id',
'join' => "JOIN `another_table` AS `r` ON `r`.`primary_id` = `t`.`primary_id`"
),
);
}
```
throws exception: `Integrity constraint violation: 1052 Column 'primary_id' in field list is ambiguous. The SQL statement executed was:`
```sql
SELECT `primary_id` AS `c`, COUNT(*) AS `s`
FROM `task` `t`
JOIN `another_table` AS `r` ON `r`.`primary_id` = `t`.`primary_id`
WHERE (`t`.`primary_id`='2560')
GROUP BY `primary_id`
```