Skip to content

Instantly share code, notes, and snippets.

@develop7
Created November 21, 2009 23:02
Show Gist options
  • Save develop7/240326 to your computer and use it in GitHub Desktop.
Save develop7/240326 to your computer and use it in GitHub Desktop.
<?php
//...snip
$q = Doctrine_Query::create()->from('Post p, p.Comments c')->select('p.*, c.*, COUNT(c.id) AS comment_count')->having('comment_count <= p.max_comments');
$q->getSql(); //produces '... HAVING a2__0 <= p.max_comments ...'
//instead of '... HAVING a2__0 <= a__max_comments ...'
Post:
columns:
content: string(1000)
max_comments: integer
relation:
Comments:
class: Comment
local: id
foreign: post_id
Comment:
columns:
post_id: integer
content: string(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment