protected function doCount()
    {
        $query = $this->getCountQuery();
        $result = $query->execute()->fetchResult();

        $this->count = intval($result['count']);
        $this->pages = intval($this->count / $this->itemsPerPage);

        if ($this->count % $this->itemsPerPage != 0) {
            $this->pages++;
        }

        if ($this->pages == 0) {
            $this->pages = 1;
        }
    }