- Phalcon\Paginator\Adapter\AbstractAdapter
- Phalcon\Paginator\Adapter\AdapterInterface
- Phalcon\Paginator\Adapter\Model
- Phalcon\Paginator\Adapter\NativeArray
- Phalcon\Paginator\Adapter\QueryBuilder
- Phalcon\Paginator\Exception
- Phalcon\Paginator\PaginatorFactory
- Phalcon\Paginator\Repository
- Phalcon\Paginator\RepositoryInterface
Abstract Class Phalcon\Paginator\Adapter\AbstractAdapter
| Namespace | Phalcon\Paginator\Adapter | | Uses | Phalcon\Paginator\Exception, Phalcon\Paginator\Repository, Phalcon\Paginator\RepositoryInterface | | Implements | AdapterInterface |
Phalcon\Paginator\Adapter\AbstractAdapter
Properties¶
/**
* Configuration of paginator
*/
protected config;
/**
* Number of rows to show in the paginator. By default is null
*/
protected limitRows;
/**
* Current page in paginate
*/
protected page;
/**
* Repository for pagination
*
* @var RepositoryInterface
*/
protected repository;
Methods¶
Phalcon\Paginator\Adapter\AbstractAdapter constructor Get current rows limit Set the current page number Set current rows limit Sets current repository for pagination Gets current repository for paginationInterface Phalcon\Paginator\Adapter\AdapterInterface
| Namespace | Phalcon\Paginator\Adapter | | Uses | Phalcon\Paginator\RepositoryInterface |
Phalcon\Paginator\AdapterInterface
Interface for Phalcon\Paginator adapters
Methods¶
Get current rows limit Returns a slice of the resultset to show in the pagination Set the current page number Set current rows limitClass Phalcon\Paginator\Adapter\Model
| Namespace | Phalcon\Paginator\Adapter | | Uses | Phalcon\Helper\Arr, Phalcon\Mvc\ModelInterface, Phalcon\Mvc\Model\ResultsetInterface, Phalcon\Paginator\Exception, Phalcon\Paginator\RepositoryInterface | | Extends | AbstractAdapter |
Phalcon\Paginator\Adapter\Model
This adapter allows to paginate data using a Phalcon\Mvc\Model resultset as a base.
use Phalcon\Paginator\Adapter\Model;
$paginator = new Model(
[
"model" => Robots::class,
"limit" => 25,
"page" => $currentPage,
]
);
$paginator = new Model(
[
"model" => Robots::class,
"parameters" => [
"columns" => "id, name"
],
"limit" => 12,
"page" => $currentPage,
]
);
$paginator = new Model(
[
"model" => Robots::class,
"parameters" => [
"type = :type:",
"bind" => [
"type" => "mechanical"
],
"order" => "name"
],
"limit" => 16,
"page" => $currentPage,
]
);
$paginator = new Model(
[
"model" => Robots::class,
"parameters" => "(id % 2) = 0",
"limit" => 8,
"page" => $currentPage,
]
);
$paginator = new Model(
[
"model" => Robots::class,
"parameters" => [ "(id % 2) = 0" ],
"limit" => 8,
"page" => $currentPage,
]
);
$paginate = $paginator->paginate();
Methods¶
Returns a slice of the resultset to show in the paginationClass Phalcon\Paginator\Adapter\NativeArray
| Namespace | Phalcon\Paginator\Adapter | | Uses | Phalcon\Paginator\Exception, Phalcon\Paginator\RepositoryInterface | | Extends | AbstractAdapter |
Phalcon\Paginator\Adapter\NativeArray
Pagination using a PHP array as source of data
use Phalcon\Paginator\Adapter\NativeArray;
$paginator = new NativeArray(
[
"data" => [
["id" => 1, "name" => "Artichoke"],
["id" => 2, "name" => "Carrots"],
["id" => 3, "name" => "Beet"],
["id" => 4, "name" => "Lettuce"],
["id" => 5, "name" => ""],
],
"limit" => 2,
"page" => $currentPage,
]
);
Methods¶
Returns a slice of the resultset to show in the paginationClass Phalcon\Paginator\Adapter\QueryBuilder
| Namespace | Phalcon\Paginator\Adapter | | Uses | Phalcon\Db\Enum, Phalcon\Mvc\Model\Query\Builder, Phalcon\Paginator\RepositoryInterface, Phalcon\Paginator\Exception | | Extends | AbstractAdapter |
Phalcon\Paginator\Adapter\QueryBuilder
Pagination using a PHQL query builder as source of data
use Phalcon\Paginator\Adapter\QueryBuilder;
$builder = $this->modelsManager->createBuilder()
->columns("id, name")
->from(Robots::class)
->orderBy("name");
$paginator = new QueryBuilder(
[
"builder" => $builder,
"limit" => 20,
"page" => 1,
]
);
Properties¶
/**
* Paginator's data
*/
protected builder;
/**
* Columns for count query if builder has having
*/
protected columns;
Methods¶
Phalcon\Paginator\Adapter\QueryBuilder Get the current page number Get query builder object Returns a slice of the resultset to show in the pagination Set query builder objectClass Phalcon\Paginator\Exception
| Namespace | Phalcon\Paginator | | Extends | \Phalcon\Exception |
Phalcon\Paginator\Exception
Exceptions thrown in Phalcon\Paginator will use this class
Class Phalcon\Paginator\PaginatorFactory
| Namespace | Phalcon\Paginator | | Uses | Phalcon\Paginator\Adapter\AdapterInterface, Phalcon\Factory\AbstractFactory, Phalcon\Helper\Arr | | Extends | AbstractFactory |
This file is part of the Phalcon Framework.
(c) Phalcon Team team@phalcon.io
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Methods¶
AdapterFactory constructor. Factory to create an instance from a Config objectuse Phalcon\Paginator\PaginatorFactory;
$builder = $this
->modelsManager
->createBuilder()
->columns("id, name")
->from(Robots::class)
->orderBy("name");
$options = [
"builder" => $builder,
"limit" => 20,
"page" => 1,
"adapter" => "queryBuilder",
];
$paginator = (new PaginatorFactory())->load($options);
Class Phalcon\Paginator\Repository
| Namespace | Phalcon\Paginator | | Uses | JsonSerializable, Phalcon\Helper\Arr | | Implements | RepositoryInterface, JsonSerializable |
Phalcon\Paginator\Repository
Repository of current state Phalcon\Paginator\AdapterInterface::paginate()
Properties¶
Methods¶
See jsonSerialize Gets value of property by name Resolve alias property nameInterface Phalcon\Paginator\RepositoryInterface
| Namespace | Phalcon\Paginator |
Phalcon\Paginator\RepositoryInterface
Interface for the repository of current state Phalcon\Paginator\AdapterInterface::paginate()
Constants¶
const PROPERTY_CURRENT_PAGE = current;
const PROPERTY_FIRST_PAGE = first;
const PROPERTY_ITEMS = items;
const PROPERTY_LAST_PAGE = last;
const PROPERTY_LIMIT = limit;
const PROPERTY_NEXT_PAGE = next;
const PROPERTY_PREVIOUS_PAGE = previous;
const PROPERTY_TOTAL_ITEMS = total_items;