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