Hi there,
I’ve made this code some time:
User::model()->findAllBySql('
SELECT DISTINCT `users`.`id` FROM `users`
LEFT JOIN `threadChilds` ON (`threadChilds`.`userId` = `users`.`id`)
LEFT JOIN `threads` ON (`threadChilds`.`threadId` = `threads`.`id`)
WHERE (`threads`.`id` = :threadId OR `users`.`id` = :threadStarter)
' . (empty($excludeIds) ? '' : ' AND `users`.`id` NOT IN (:excludeIds)'),$params)
But it resulted in: "Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 76 bytes) in yiilite.php on line 679"
Then i tried:
User::model()->findAllBySql('
SELECT DISTINCT `users`.* FROM `users`
LEFT JOIN `threadChilds` ON (`threadChilds`.`userId` = `users`.`id`)
LEFT JOIN `threads` ON (`threadChilds`.`threadId` = `threads`.`id`)
WHERE (`threads`.`id` = :threadId OR `users`.`id` = :threadStarter)
' . (empty($excludeIds) ? '' : ' AND `users`.`id` NOT IN (:excludeIds)'),$params)
which works just fine.
Can anybody tell me why? There’s no reason to select all fields, when I only need the ID?
Thanks.