We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

pagination problem

when i want to paginate from query builder i got an error on below

Fatal error: Phalcon\Paginator\Adapter\QueryBuilder::getPaginate() [<a href='phalcon\paginator\adapter\querybuilder.getpaginate'>phalcon\paginator\adapter\querybuilder.getpaginate</a>]: Call to undefined method limit() on class Phalcon\Mvc\Model\Resultset\Simple in C:\wamp\www\popsbuy\app\controllers\OrdersController.php on line 65

My Code:

$orders = $order->getUserOrders(); 

$paginator = new Phalcon\Paginator\Adapter\QueryBuilder(array(
    "builder" => $orders,
    "limit" => 20,
    "page" => 1

// Get the paginated results
$page = $paginator->getPaginate();


İ solve the problem , its cuz of after createBuilder i add execute()


Now another problem i want to learn is , when pagination is there any feature about get page numbers ?

i mean in codeigniter etc we can set the page numbers and when add it on page it is:

<<back 1 2 3 ... 8 9 10 next>>

Can i do that ?


The paginator does not have a feature like the one you are describing.

I use this simple method in Volt:

<ul class="pager">
    {% for index in 1..page.total_pages %}
        <li>{{ link_to("/list?page=" ~ index, index) }}</li>
    {% endfor %}
edited May '14

how to achieve pagination feature like displaying information (ex: display 5 to 10 from 100 rows). thx. I can't get totals based on conditions and limit. (in mysql: select SQL_CALC_FOUND_ROWS a, b from c where name like 'a%' limit 10)