Skip to content

Instantly share code, notes, and snippets.

View gondo's full-sized avatar
🎯
Focusing

gondo gondo

🎯
Focusing
View GitHub Profile
@gondo
gondo / KnpPaginatorQuerySubscriber
Last active August 29, 2015 14:07
fixing random pagination results in knp_paginator and mysql
<?php
namespace General\GeneralBundle\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Knp\Component\Pager\Event\ItemsEvent;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
class KnpPaginatorQuerySubscriber implements EventSubscriberInterface
@gondo
gondo / controller
Created July 22, 2014 18:57
KnpPaginatorBundle multiple paginators example
public function listAction()
{
$em = $this->getDoctrine()->getManager();
$repository = $em->getRepository('ExampleBundle:Entity');
$qb = $historyRepository->createQueryBuilder('EntityAlias');
$knpPaginator = $this->get('knp_paginator');
$paginationAAA = $knpPaginator->paginate(
$qb,