Abstract class Phalcon\Paginator\Adapter
implements Phalcon\Paginator\AdapterInterface
Source on GitHub
Methods
public setCurrentPage (mixed $page)
Set the current page number
public setLimit (mixed $limitRows)
Set current rows limit
public getLimit ()
Get current rows limit
abstract public getPaginate () inherited from Phalcon\Paginator\AdapterInterface
…
Class Phalcon\Paginator\Adapter\Model
extends abstract class Phalcon\Paginator\Adapter
implements Phalcon\Paginator\AdapterInterface
Source on GitHub
This adapter allows to paginate data using a Phalcon\Mvc\Model resultset as a base.
<?php
use Phalcon\Paginator\Adapter\Model;
$paginator = new Model(
[
"data" => Robots::find(),
"limit" => 25,
"page" => $currentPage,
]
);
$paginate = $paginator->getPaginate();
Methods
public __construct (array $config)
Phalcon\Paginator\Adapter\Model constructor
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
Class Phalcon\Paginator\Adapter\NativeArray
extends abstract class Phalcon\Paginator\Adapter
implements Phalcon\Paginator\AdapterInterface
Source on GitHub
Pagination using a PHP array as source of data
<?php
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
public __construct (array $config)
Phalcon\Paginator\Adapter\NativeArray constructor
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
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
Interface Phalcon\Paginator\AdapterInterface
Source on GitHub
Methods
abstract public setCurrentPage (mixed $page)
…
abstract public getPaginate ()
…
abstract public setLimit (mixed $limit)
…
abstract public getLimit ()
…
Class Phalcon\Paginator\Exception
extends class Phalcon\Exception
implements Throwable
Source on GitHub
Methods
final private Exception __clone () inherited from Exception
Clone the exception
public __construct ([mixed $message], [mixed $code], [mixed $previous]) inherited from Exception
Exception constructor
public __wakeup () inherited from Exception
…
final public string getMessage () inherited from Exception
Gets the Exception message
final public int getCode () inherited from Exception
Gets the Exception code
final public string getFile () inherited from Exception
Gets the file in which the exception occurred
final public int getLine () inherited from Exception
Gets the line in which the exception occurred
final public array getTrace () inherited from Exception
Gets the stack trace
final public Exception getPrevious () inherited from Exception
Returns previous Exception
final public Exception getTraceAsString () inherited from Exception
Gets the stack trace as a string
public string __toString () inherited from Exception
String representation of the exception
Class Phalcon\Paginator\Factory
extends abstract class Phalcon\Factory
implements Phalcon\FactoryInterface
Source on GitHub
Loads Paginator Adapter class using ‘adapter’ option
<?php
use Phalcon\Paginator\Factory;
/**
* The `modelsManager` is automatically created when you instantiate your DI
* container using the `FactoryDefault` class. It returns a
* [Phalcon\Mvc\Model\Manager](/3.4/en/api/Phalcon_Mvc_Model_Manager) object
*/
$builder = $this->modelsManager->createBuilder()
->columns("id, name")
->from("Robots")
->orderBy("name");
$options = [
"builder" => $builder,
"limit" => 20,
"page" => 1,
"adapter" => "queryBuilder",
];
$paginator = Factory::load($options);
Methods
public static load (Phalcon\Config | array $config)
protected static loadClass (mixed $namespace, mixed $config) inherited from Phalcon\Factory
…