Question

my problem is, every time I click in the paginator link in the view, the controller returns me this error:

Syntax error, unexpected EOF

What is this? EOF?

My controller:

$domicilios = Domicilios::find();

$paginator = new \Phalcon\Paginator\Adapter\Model(
array(
"data" => $domicilios,
"limit"=> 5,
"page" => $currentPage
)
);

$pagina = $paginator->getPaginate();

$this->view->setVar("estado", $estado);
$this->view->setVar("pagina", $pagina);

The content in the model Domicilios is returning right, but why the paginator keeps returning this error?

Thanks in advance!

Was it helpful?

Solution

EOF is end of file. there might be several issues. 1stly if you upload this file to server, there might be problems with upload process and file is not fully uploaded and you have broken end of file (EOF).

try converting your php file to utf8. you can do it with notepad++ and many other programs.

here are my working pagination:

    $page = $this->request->get('page', 'int', 1);
    $this->view->page = $page;
    if ($page < 1) {
        $page = 1;
    }
    $user = $this->session->get('auth');
    $questions = Model_UserQuestion::find(array(
                'user_id=:user_id:',
                'bind' => array('user_id' => $user['id']),
                "order" => "id DESC",
    ));

    // Create a Model paginator, show 10 rows by page starting from $currentPage
    $paginator = new \Phalcon\Paginator\Adapter\Model(
            array(
        "data" => $questions,
        "limit" => $this->config->application->itemsPerPage,
        "page" => $page
            )
    );
    $page = $paginator->getPaginate();
    $this->view->questions = $page->items;

notice that to get items you have to use this:

$page->items
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top