內容目录

上一个主题

< Class Phalcon\Paginator\Adapter\NativeArray

下一个主题

Class Phalcon\Paginator\Exception >

Phalcon玩家群:150237524Phalcon玩家

Class Phalcon\Paginator\Adapter\QueryBuilder

extends abstract class Phalcon\Paginator\Adapter

implements Phalcon\Paginator\AdapterInterface

Source on GitHub

Pagination using a PHQL query builder as source of data

<?php

use Phalcon\Paginator\Adapter\QueryBuilder;

$builder = $this->modelsManager->createBuilder()
                ->columns("id, name")
                ->from("Robots")
                ->orderBy("name");

$paginator = new QueryBuilder(
    [
        "builder" => $builder,
        "limit"   => 20,
        "page"    => 1,
    ]
);

Methods

public __construct (array $config)

public getCurrentPage ()

Get the current page number

public setQueryBuilder (Phalcon\Mvc\Model\Query\Builder $builder)

Set query builder object

public getQueryBuilder ()

Get query builder object

public getPaginate ()

Returns a slice of the resultset to show in the pagination

public setCurrentPage (mixed $page) inherited from Phalcon\Paginator\Adapter

Set the current page number

public setLimit (mixed $limitRows) inherited from Phalcon\Paginator\Adapter

Set current rows limit

public getLimit () inherited from Phalcon\Paginator\Adapter

Get current rows limit