Postagens populares

quarta-feira, 11 de novembro de 2015

Doctrine 2 Generic Paginator

Sometimes you need to write DQL's for the fast bulding time it gives you, other times you need intricate  queries that cannot be built or are very expensive in DQL.

Pagination of each of these is a pain in the ass. Don't suffer no more!

It is based on PagerFanta for Doctrine 2: Pagerfanta

Doctrine 2 Generic Paginator

It works with either DQL or SQL queries built by respective Query Builders.

Pagerfanta supports adapters, but it is the same concept, except that i have encapsulated.

$qb = new QueryBuilder($this->getDoctrine()->getConnection()); $pag = new DoctrinePaginator($qb, 'COUNT(a.id) as total_rows'); $pag->setMax(25); $pag->setPage($this->getRequest()->query->get('page', 1)); $pag->getResults();

No need to thank ;)

Nenhum comentário:

Postar um comentário

Comenta aí galera, vamos debater os assuntos!

Magazine Luiza