The Friendly Web Guys

The Jimmyweb Blog

Symfony Tip: Propel pager with group-by returns incorrect total

27th
June

2009

Posted by James Beattie - under Developer 2 Comments

tip

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!

Tags used in this post:
,

Share this post:
Share Share Share Share Share

2 Comments

gravatar

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

gravatar

charlie says:

January 7th, 2010

thanks! just what i was looking for

Leave a Comment