title: Why does column alias not work in doctrine?
body: <p>My script is like this:</p>
  
  <pre><code>$query = Doctrine_Query::create ()
    -&gt;select('count(p.product_id) as num_a')              
    -&gt;from ( 'ProductComments p' )
    -&gt;groupBy('p.product_id')
    -&gt;having('num_a =2 ');
  </code></pre>
  
  <p>And the generated sql is:</p>
  
  <pre><code>SELECT COUNT(i.product_id) AS i__0 FROM productcomments i GROUP BY i.product_id HAVING num_a=2
  </code></pre>
  
  <p>Thus I get an error when execute the sql.</p>
  
  <p>I have two questions:</p>
  
  <ol>
  <li><p>why is the alias of the table <code>'i'</code> instead of <code>'p'</code>?</p></li>
  <li><p>why is the <code>'num_a'</code> in having clause not replaced with <code>'i__0'</code>,how to fixed it?</p></li>
  </ol>
  
  <p>Thanks for your suggestion...</p>