I did some tests, and I found that everything seemed perfect.
Video: id, title, ... Comment: id, video_id, content, ...
The database schema is very simple, and I think there is no explanation.
#DQL: SELECT v.id, COUNT(c.id) AS num FROM Video v JOIN v.comments c GROUP BY v.id ORDER BY num DESC
If you select the entire Video object instead of your id ( v instead of v.id in SELECT ), the query will also be executed. Of course, instead of the id element, there will be a Video object under the 0 th element.
Tested on Doctrine 2.1.0-DEV
source share