Table Of Contents

Previous topic

< Class Phalcon\Paginator\Adapter\Model

Next topic

Class Phalcon\Paginator\Adapter\QueryBuilder >

Class Phalcon\Paginator\Adapter\NativeArray

implements Phalcon\Paginator\AdapterInterface

Pagination using a PHP array as source of data

<?php

$paginator = new \Phalcon\Paginator\Adapter\Model(
    array(
            "data"  => array(
                    array('id' => 1, 'name' => 'Artichoke'),
                    array('id' => 2, 'name' => 'Carrots'),
                    array('id' => 3, 'name' => 'Beet'),
                    array('id' => 4, 'name' => 'Lettuce'),
                    array('id' => 5, 'name' => '')
            ),
            "limit" => 2,
            "page"  => $currentPage
    )
);

Methods

public __construct (array $config)

Phalcon\Paginator\Adapter\NativeArray constructor

public setCurrentPage (int $page)

Set the current page number

public stdClass getPaginate ()

Returns a slice of the resultset to show in the pagination