Adldap\Query\Builder::paginate PHP Method

paginate() public method

Paginates the current LDAP query.
public paginate ( integer $perPage = 50, integer $currentPage, boolean $isCritical = true ) : Paginator | boolean
$perPage integer
$currentPage integer
$isCritical boolean
return Adldap\Objects\Paginator | boolean
    public function paginate($perPage = 50, $currentPage = 0, $isCritical = true)
    {
        $this->paginated = true;
        $pages = [];
        $cookie = '';
        do {
            $this->connection->controlPagedResult($perPage, $isCritical, $cookie);
            // Run the search.
            $resource = $this->connection->search($this->getDn(), $this->getQuery(), $this->getSelects());
            if ($resource) {
                $this->connection->controlPagedResultResponse($resource, $cookie);
                // We'll collect each resource result into the pages array.
                $pages[] = $resource;
            }
        } while (!empty($cookie));
        $paginator = $this->newProcessor()->processPaginated($pages, $perPage, $currentPage);
        // Reset paged result on the current connection. We won't pass in the current $perPage
        // parameter since we want to reset the page size to the default '1000'. Sending '0'
        // eliminates any further opportunity for running queries in the same request,
        // even though that is supposed to be the correct usage.
        $this->connection->controlPagedResult();
        return $paginator;
    }