Symfony Tip: Propel pager with group-by returns incorrect total
27th
June
2009
Posted by James Beattie - under Developer 2 Comments

A quick tip for those getting incorrect record totals (and thus broken paging) when using the propel pager in Symfony:
Add the following method to your pager object:
$pager->setPeerCountMethod('getGroupedCount');
Then create the following method in your peer class:
public static function getGroupedCount($c)
{
$copy = clone $c;
// this should be the intended grouping column
$copy->addGroupByColumn(parent::ID);
return parent::doCount($copy);
}
Your pager will now work the way you want it to!
2 Comments
mike says:
July 21st, 2009
Hi
I just like to say you thanks you a lot. After I spent many hours to solve this problem without success your fix did it.
Un grand merci.
Thanks.
Regards
charlie says:
January 7th, 2010
thanks! just what i was looking for
Leave a Comment