Why does column alias not work in doctrine?

ericachicken

New Member
My script is like this:\[code\]$query = Doctrine_Query::create () ->select('count(p.product_id) as num_a') ->from ( 'ProductComments p' ) ->groupBy('p.product_id') ->having('num_a =2 ');\[/code\]And the generated sql is:\[code\]SELECT COUNT(i.product_id) AS i__0 FROM productcomments i GROUP BY i.product_id HAVING num_a=2\[/code\]Thus I get an error when execute the sql.I have two questions:[*]why is the alias of the table \[code\]'i'\[/code\] instead of \[code\]'p'\[/code\]?[*]why is the \[code\]'num_a'\[/code\] in having clause not replaced with \[code\]'i__0'\[/code\],how to fixed it?Thanks for your suggestion...
 
Back
Top