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

[Problem] Return IndexController when call method getPaginate() in another Controller

I have two Controller






namespace Project\Backend\Controllers;

use Project\Backend\Models\Teams;

class TestController extends \Phalcon\Mvc\Controller
    public function indexAction()
            "action" => "list"

    public function listAction()
        $moods = Moods::find();
        $paginator = new \Phalcon\Paginator\Adapter\Model(array(
            "data" => $moods,
            "limit"=> 20,
            "page" => 1

        $page = $paginator->getPaginate(); // Problem
        $this->view->setVar('moods', $page->items);

When i call method getPaginate(), Phalcon is return IndexController :(, but when remove this line, Phalcon return TestController.

My server:

Phalcon version 1.3.1
PHP Version 5.5.11

PHP loaded extensions:

Core, date, ereg, libxml, openssl, pcre, sqlite3, zlib, bcmath, calendar, ctype, curl, dom, filter, ftp, gd, hash, iconv, SPL, json, mbstring, mcrypt, session, mysql, standard, Phar, posix, Reflection, mysqlnd, SimpleXML, sockets, imap, tokenizer, xml, xmlreader, xmlwriter, cgi-fcgi, PDO, pdo_sqlite, mongo, pdo_mysql, phalcon

Please help me

Hi I just read the pagination documentation of phalcon just like this.

$paginator = new \Phalcon\Paginator\Adapter\Model(
          "data" => $robots,
          "limit"=> 10,
          "page" => $currentPage

I think you just need to change "builder" into "data"

$paginator = new \Phalcon\Paginator\Adapter\Model(array(
            "builder" => $moods, //change this into "data" => $moods,
            "limit"=> 20,
            "page" => 1


Yes. Thank you! I'm a little confused. I was change builder in to data. But the issue remains undecided. :(