Created
March 6, 2012 12:37
-
-
Save peterjmit/1986048 to your computer and use it in GitHub Desktop.
Revisions
-
peterjmit revised this gist
Mar 6, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ function paginate(Doctrine\ORM\Query $query, $page, $limit, $fetchJoinCollection $query->setFirstResult($offset); $query->setMaxResults($limit); $paginator = new Doctrine\ORM\Tools\Pagination\Paginator($query, $fetchJoinCollection); // Num results $count = $paginator->count(); -
peterjmit revised this gist
Mar 6, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ <?php function paginate(Doctrine\ORM\Query $query, $page, $limit, $fetchJoinCollection = true) { // If we don't have a page just return the result if( ! $page && ! $limit) -
peterjmit created this gist
Mar 6, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ <?php function paginate(Doctrine\ORM\Query $query, $page, $limit) { // If we don't have a page just return the result if( ! $page && ! $limit) { return $query->getResult(); } $offset = ($page * $limit) - $limit; $query->setFirstResult($offset); $query->setMaxResults($limit); $paginator = new Doctrine\ORM\Tools\Pagination\Paginator($query); // Num results $count = $paginator->count(); $pagination_info = array( 'total' => (int) $count, 'current_page' => (int) $page, 'total_pages' => (int) ceil($count / $limit) ); return array( 'result' => $paginator, // could just return $paginator->getIterator() 'meta' => $pagination_info ); }