I'm using pagination from https://github. Com/beberlei/DoctrineExtensions it works great, at least for me Edit : Not sure this will help you, but here's how I did my pagination Controller Create the query $qb = $this->_em->createQueryBuilder(); $qb->select('p') ->from('Identiti_Entities_Pengguna', 'p'); // Sorting $qb->addOrderBy('p. ' .
$input->sort, $input->dir); $q = $qb->getQuery(); // Pagination $itemPerPage = 100; $records = new Zend_Paginator( new DoctrineExtensions\Paginate\PaginationAdapter($q)); $records->setCurrentPageNumber($input->page) ->setItemCountPerPage($itemPerPage) ->setPageRange(10); $this->view->records = $records View? Echo $this->paginationControl($this->records, 'Sliding', 'partials/pagination. Phtml');?Pagination.
Html? Php if ($this->pageCount):? > Pages: pageCount?
> previous)):? > url(array('page' => $this->previous));? >"> current):?
> url(array('page' => $page));? >"> next)):? > url(array('page' => $this->next));?
>"> Next > Next.
I'm using pagination from https://github. Com/beberlei/DoctrineExtensions, it works great, at least for me. Edit: Not sure this will help you, but here's how I did my pagination Controller // Create the query $qb = $this->_em->createQueryBuilder(); $qb->select('p') ->from('Identiti_Entities_Pengguna', 'p'); // Sorting $qb->addOrderBy('p.' .
$input->sort, $input->dir); $q = $qb->getQuery(); // Pagination $itemPerPage = 100; $records = new Zend_Paginator( new DoctrineExtensions\Paginate\PaginationAdapter($q)); $records->setCurrentPageNumber($input->page) ->setItemCountPerPage($itemPerPage) ->setPageRange(10); $this->view->records = $records; View paginationControl($this->records, 'Sliding', 'partials/pagination. Phtml');? > pagination.
Html pageCount):? > Pages: pageCount? > previous)):?
> url(array('page' => $this->previous));? >"> current):? > url(array('page' => $page));?
>"> next)):? > url(array('page' => $this->next));? >"> Next > Next.
1 There is also a extension called LargeCollections too beside the Paginate extension. – Orhan Jan 29 at 9:13 where would you use the pagination code then. In $post->getComments()?
Can we use DQL in the entity? Or maybe in a service? Can you give a code example?
@orhan same issue, where would you use the LargeCollection extension? – boosis Jan 29 at 10:50 LargeCollections did the trick for me! I added the following method to my Post entity.
Public function getCommentsPagination($limit = 10, $offset = 0) { $lc = new \DoctrineExtensions\LargeCollections\LargeCollection(); $result = $lc->getSliceQuery($this->getComments(), $limit, $offset)->getResult(); return $result; } – boosis Jan 29 at 22:42 Sorry for the formatting. I couldn't find how to format comments here. – boosis Jan 29 at 22:45 But is it correct to add such dependency in an Entity which should be persistance layer free?
– JohnT Jan 297 at 13:27.
You may consider implementing Zend_Paginator_Adapter_Interface. See ZF docs for more details: Zend Framework: Documentation: Advanced usage - Zend Framework Manual.
I don't want to do this Zend way. I am trying to accomplish this DDD/Doctrine2 way :) – boosis Jan 28 at 22:47 1 @boosis - Zend and DDD are not mutually exclusive, can you explain your comment? – jsuggs Jan 31 at 15:29.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.