yii\data\Pagination::getPageCount PHP Method

getPageCount() public method

public getPageCount ( ) : integer
return integer number of pages
    public function getPageCount()
    {
        $pageSize = $this->getPageSize();
        if ($pageSize < 1) {
            return $this->totalCount > 0 ? 1 : 0;
        } else {
            $totalCount = $this->totalCount < 0 ? 0 : (int) $this->totalCount;
            return (int) (($totalCount + $pageSize - 1) / $pageSize);
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Adds HTTP headers about the pagination to the response.
  * @param Pagination $pagination
  */
 protected function addPaginationHeaders($pagination)
 {
     $links = [];
     foreach ($pagination->getLinks(true) as $rel => $url) {
         $links[] = "<{$url}>; rel={$rel}";
     }
     $this->response->getHeaders()->set($this->totalCountHeader, $pagination->totalCount)->set($this->pageCountHeader, $pagination->getPageCount())->set($this->currentPageHeader, $pagination->getPage() + 1)->set($this->perPageHeader, $pagination->pageSize)->set('Link', implode(', ', $links));
 }
All Usage Examples Of yii\data\Pagination::getPageCount