My script is like this:
$query = Doctrine_Query::create () ->select(\'count(p.product_id) as num_a\') ->from ( \'ProductComments p\'
I also had a problem with setting alias. I had to set alias and then use "ORDER BY" with that alias. Following solution worked for me:
$myQuery->addSelect('() AS my_alias'); $myQuery->orderBy('my_alias');
In the result query looked like "...() AS p_0 ... ORDER BY p_0". I hope it will help someone.