Doutrina - subconsulta a partir de
Eu tenho uma consulta no MySQL:
SELECT * FROM (
SELECT COUNT(*) AS count, t.name AS name
FROM tag t
INNER JOIN video_has_tag v USING (idTag)
GROUP BY v.idTag
ORDER BY count DESC
LIMIT 10
) as tags ORDER BY name
e quero escrever isso em doutrina. Como eu posso fazer isso? Eu escrevi:
Doctrine_Query::create()
->select('COUNT(t.idtag) as count, t.name')
->from('Tag t')
->innerJoin('t.VideoHasTag v')
->groupBy('v.idTag')
->orderBy('count DESC, t.name')
->limit(30)
->execute();
Mas não posso colocá-lo em "from" para classificar por nome.