PHP code example of nsm / doctrine-paginator

1. Go to this page and download the library: Download nsm/doctrine-paginator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nsm / doctrine-paginator example snippets


// $qb is a Doctrine QueryBuilder object
$p = new \Nsm\DoctrinePaginator\DoctrinePaginator($qb);

var_dump(
    array(
        'currentPageNumber' => $p->getCurrentPageNumber(),
        'currentPageResults' => $p->getCurrentPageResults(),
        'currentPageResultCount' => $p->getCurrentPageResultCount(),
        'currentPageFirstResultPositionInTotalResults' => $p->getCurrentPageFirstResultPositionInTotalResults(),
        'currentPageLastResultPositionInTotalResults' => $p->getCurrentPageLastResultPositionInTotalResults(),
        'maxPageNumber' => $p->getMaxPerPageNumber(),
        'hasPreviousPage' => $p->hasPreviousPage($pNum),
        'previousPageNumber' => $p->hasPreviousPage($pNum) ? $p->getPreviousPageNumber($pNum) : false,
        'hasNextPage' => $p->hasNextPage($pNum),
        'nextPageNumber' => $p->hasNextPage($pNum) ? $p->getNextPageNumber($pNum) : false,
        'totalPageCount' => $p->getTotalPageCount(),
        'totalResultCount' => $p->getTotalResultCount(),
        'canPaginate' => $p->canPaginate(),
        'pageRangeForPage' => $p->getPageRangeForPage(3)
     )
);