Any idea why even if I select the id it still selects everything in the query:
$role = $this->with ( 'users' )->together ()->find
(
array
(
'select' => 'id',
'condition' => 'user_id=:user_id',
'params' => array ( ':user_id' => $user_id ),
'limit' => 1,
'order' => 'rank DESC'
)
);
This is the generated code:
system.db.CDbCommand.query(SELECT `WB_Roles`.`id` AS `t0_c0`, users.`id` AS `t1_c0`, users.`is_active` AS `t1_c1`, users.`email` AS `t1_c2`, users.`username` AS `t1_c3`, users.`password` AS `t1_c4`, users.`confirmation_code` AS `t1_c5`, users.`date_added` AS `t1_c6` FROM `WB_Roles` LEFT OUTER JOIN `wb_user_roles` users_users ON (`WB_Roles`.`id`=users_users.`role_id`) LEFT OUTER JOIN `WB_Users` users ON (users.`id`=users_users.`user_id`) WHERE (user_id=:user_id) ORDER BY rank DESC LIMIT 1)
Maybe I’m doing something wrong but it’s obvious that it extracts everything even if specified that only the id should be extracted,