'hnp' => array(self::STAT, 'Request', 'agent_id', 'select'=>'SUM(hnp.total_due)'),
Where Agent has many Requests.
This throws an exception that hnp.total_due does not exists. But when i change it to t.total_due the results are ok.
This behavior is different than what is written in Yii's Definitive Guide, which is as following:-
In relational AR query, the alias name for the primary table is fixed as t, while the alias name for a relational table is the same as the corresponding relation name by default. For example, in the following statement, the alias name for Post and Comment is t and comments, respectively:
Now assume both Post and Comment have a column called create_time indicating the creation time of a post or comment, and we would like to fetch posts together with their comments by ordering first the posts' creation time and then the comments' creation time. We need to disambiguate the create_time column like the following:
$posts=Post::model()->with('comments')->findAll(array( 'order'=>'t.create_time, comments.create_time' ));
Can someone explain whether i am doing it wrong, or Yii Guide needs to be improved.