Skip to content

Instantly share code, notes, and snippets.

@ringmaster
Created March 1, 2013 16:35
Show Gist options
  • Save ringmaster/5065881 to your computer and use it in GitHub Desktop.
Save ringmaster/5065881 to your computer and use it in GitHub Desktop.
Get Habari posts ordered by how many comments they have
$presets['most_comments'] = array(
'on_query_built' => function(Query $query) {
$query->join('LEFT JOIN {comments} c ON c.post_id = {posts}.id');
$query->groupby('{posts}.id');
$query->orderby('count(c.id) DESC');
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment