Returns the current page number for the list.

This will override the current page number provided by the user if it is past the last page of available records.

@param object $query
@return int
509054
protected function getCurrentPageNumber($query)
    {
        $currentPageNumber = $this->currentPageNumber;

        if (!$currentPageNumber && empty($this->searchTerm)) {
            // Restore the last visited page from the session if available.
            $currentPageNumber = $this->getSession('lastVisitedPage');
        }

        $currentPageNumber = intval($currentPageNumber);

        if ($currentPageNumber > 1) {
            $count = $query->count();

            // If the current page number is higher than the amount of available pages, go to the last available page
            if ($count <= (($currentPageNumber - 1) * $this->recordsPerPage)) {
                $currentPageNumber = ceil($count / $this->recordsPerPage);
            }
        }

        return $currentPageNumber;
    }
80583
public function count(array $query = [])
    {
        $partial = Inflector::pluralize($this->getResourceName()).'/count';

        return $this->client->get($partial, $query)['count'];
    }
502401
public function query($query)
    {
        // If the query is empty, we'll return false
        if ($query === null || empty($query)) {
            return false;
        }

        if ($this->read) {
            // If read is true, we'll perform a read search, retrieving one record
            $results = $this->connection->read($this->getDn(), $query, $this->getSelects());
        } elseif ($this->recursive) {
            // If recursive is true, we'll perform a recursive search
            $results = $this->connection->search($this->getDn(), $query, $this->getSelects());
        } else {
            // Read and recursive is false, we'll return a listing
            $results = $this->connection->listing($this->getDn(), $query, $this->getSelects());
        }

        if ($results) {
            return $this->processResults($results);
        }

        return false;
    }
32675
public function getPageCount() : int
    {
        return intval($this->count / $this->pageSize) + ($this->count % $this->pageSize == 0 ? 0 : 1);
    }
168025
private function getPage(Request $request)
    {
        $page = $request->query->get('page', 1);
        if (!is_numeric($page) || $page < 1) {
            $page = 1;
        }

        return (int)$page;
    }
98655
function getPageCount() {
		if (!$this->limit) {
			return 1;
		}
		$rem = ($this->getTotal() % $this->limit);
		$rem = ($rem >= 0) ? $rem : 0;
		$total_pages = ($this->getTotal() - $rem) / $this->limit;
		if ($rem)
			$total_pages++;
		return $total_pages;
	}
473412
protected function getPaginationData(Select $query, array $options)
    {
        // Get pagination options
        $page = (int) Arr::get($options, 'page');

        if ($page < 1) {
            $page = 1;
        }

        $resultsPerPage = Arr::get(
            $options,
            'resultsPerPage',
            $this->resultsPerPage
        );

        // Get total results
        $resultCount = $this->getQueryResultCount($query);
        $pageCount   = ceil($resultCount / $resultsPerPage);

        return new PaginationData([
            'page'             => $page,
            'page_count'       => $pageCount,
            'result_count'     => $resultCount,
            'results_per_page' => $resultsPerPage
        ]);
    }
1203863
public static function fix_number_posts_wp_quirk( $query ) {
		if ( isset($query->query) && isset($query->query['numberposts'])
				&& !isset($query->query['posts_per_page']) ) {
			$query->set('posts_per_page', $query->query['numberposts']);
		}
		return $query;
	}
1231598
public function getMyNumPage($page = null)
    {
        if ($page === null) {
            $page = $this->page;
        }

        if ($this->_myLastPageGroupNb == 0) {
            return $page;
        } else {
            return $page-$this->_myLastPageGroup;
        }
    }
623269
public function getTotalPages()
    {
        // Pages before
        $pages = ceil(($this->getFirstShown() - 1) / $this->getItemsPerPage());

        // Current page
        $pages++;

        // Pages after
        $pages += ceil(($this->getTotalRecords() - $this->getLastShown()) / $this->getItemsPerPage());

        return (int) $pages;
    }
889529
protected function _scope($query)
    {
        $scope = $this->getConfig('scope');

        if (is_array($scope)) {
            return $query->where($scope);
        }
        if (is_callable($scope)) {
            return $scope($query);
        }

        return $query;
    }
330768
function queryColumn($query)
  {
    $data = [];
    $res = $this->q($query);
    while ($row = $res->fetch_row())
    {
      if ($res->field_count == 1)
        $data[] = $row[0];
      else
        $data[$row[0]] = $row[1];
    }
    $res->close();
    return $data;
  }
1043574
public function get_pagenum()
    {
        $pagenum = isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 0;

        if (isset($this->pagination_args['total_pages']) && $pagenum > $this->pagination_args['total_pages']) {
            $pagenum = $this->pagination_args['total_pages'];
        }

        return max(1, $pagenum);
    }
340153
protected function getItemsPerPage()
    {
        $perPage = (int)$this->resultSet->getUsedSearch()->getQuery()->getRows();
        return $perPage > 0 ? $perPage : 10;
    }
608743
protected function getQueryResultCount(Select $query)
    {
        $queryString = $this->getSqlObject()->getSqlStringForSqlObject($query, $this->dbAdapter->getPlatform());

        $format = 'Select count(*) as `count` from (%s) as `query_count`';

        $countQueryString = sprintf($format, $queryString);

        $countQuery = $this->dbAdapter->query($countQueryString);

        $result = $countQuery->execute()->current();

        return (int) Arr::get($result, 'count');
    }
802758
public final function count(string $query = null, array $queryParams = null): ?int
    {
        $queryBuilder = new QueryBuilder($this->db->getLink());
        $queryBuilder->setTable($this->table);

        if ($query || $queryParams) {
            $queryBuilder->where($query, $queryParams);
        }

        return $queryBuilder->count();
    }
1334384
public static function getRow($query)
    {
        $ret = null;

        $res = self::query($query);
        if ($res) {
            if ($row = self::connection()->sql_fetch_assoc($res)) {
                $ret = $row;
            }
            self::free($res);
        }

        return $ret;
    }