Paginator error: Syntax error, unexpected EOF

Hi guys, 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!



84.5k

Could you please submit a backtrace of the exception?

try {
//...
} catch (Exception $e) {
   echo $e->getMessage();
   echo $e->getTraceAsString();
}

Can you also post the view? i.e. how do you present the data to the user?

edited Mar '14

@Phalcon:

I used the try/catch and:

Syntax error, unexpected EOF

#0 [internal function]: Phalcon\Mvc\Model\Query->parse() #1 [internal function]: Phalcon\Mvc\Model\Query->execute(NULL, NULL) #2 C:\wamp\www\azzuadmint1\app\controllers\RelatoriosController.php(42): Phalcon\Mvc\Model::find(Array) #3 [internal function]: RelatoriosController->gerarAction() #4 [internal function]: Phalcon\Dispatcher->dispatch() #5 C:\wamp\www\azzuadmint1\public\index.php(27): Phalcon\Mvc\Application->handle() #6 {main}

@Nikolaos Dimopoulos:

Here is my view, I removed some not important parts:

My table, removed "table" and "th" tags only to post here:

<?php
foreach($page->items as $item){
?>
    <tr>
        <td><?=$item->nome?></td>
        <td><?=$item->telefone?></td>
        <td><?=$item->endereco?></td>
        <td><?=$item->numero?></td>
        <td><?=$item->complemento?></td>
        <td><?=$item->observacao?></td>
        <td></td>
        <td></td>
    </tr>
<?php
}
?>

<div id="paginacao">                
    <a href="gerar">First</a>
    <a href="gerar?page=<?= $page->before; ?>">Previous</a>
    <a href="gerar?page=<?= $page->next; ?>">Next</a>
    <a href="gerar?page=<?= $page->last; ?>">Last</a>
    <?php echo "You are in page ", $page->current, " of ", $page->total_pages; ?>
</div>

Thanks for your replies!

Shouldn't that be:

<?php
foreach($pagina->items as $item){
?>

and

<div id="paginacao"> 
<a href="gerar">First</a>
<a href="gerar?page=<?= $pagina->before; ?>">Previous</a>
<a href="gerar?page=<?= $pagina->next; ?>">Next</a>
<a href="gerar?page=<?= $pagina->last; ?>">Last</a>
<?php echo "You are in page ", $pagina->current, " of ", $pagina->total_pages; ?>
</div>


84.5k

Could you please post your model?

No hahah, sorry, I changed to page today to see if it will fix the problem, but no success :/ I really don't know what to do, :(

edited Mar '14
<?php

class Domicilios extends \Phalcon\Mvc\Model
{

    /**
     *
     * @var integer
     */
    public $id;

    /**
     *
     * @var integer
     */
    public $id_usuario;

    /**
     *
     * @var string
     */
    public $nome;

    /**
     *
     * @var integer
     */
    public $codigo;

    /**
     *
     * @var string
     */
    public $perfil;

    /**
     *
     * @var string
     */
    public $endereco;

    /**
     *
     * @var integer
     */
    public $numero;

    /**
     *
     * @var string
     */
    public $complemento;

    /**
     *
     * @var string
     */
    public $observacao;

    /**
     *
     * @var string
     */
    public $telefone;

    /**
     *
     * @var string
     */
    public $data_visita;

    /**
     *
     * @var integer
     */
    public $status;

    /**
     * Independent Column Mapping.
     */
    public function columnMap() {
        return array(
            'id' => 'id', 
            'id_usuario' => 'id_usuario', 
            'nome' => 'nome', 
            'codigo' => 'codigo', 
            'perfil' => 'perfil', 
            'endereco' => 'endereco', 
            'numero' => 'numero', 
            'complemento' => 'complemento', 
            'observacao' => 'observacao', 
            'telefone' => 'telefone', 
            'data_visita' => 'data_visita', 
            'status' => 'status'
        );
    }

}

This is my model, generated using phalcon devtools.

If we assume that the table you store your data is called

domicilios

Then change your model like this and try again:

class Domicilios extends \Phalcon\Mvc\Model
{
    public $id;
    public $id_usuario;
    public $nome;
    public $codigo;
    public $perfil;
    public $endereco;
    public $numero;
    public $complemento;
    public $observacao;
    public $telefone;
    public $data_visita;
    public $status;

    public function columnMap() 
    {
        return array(
            'id'          => 'id', 
            'id_usuario'  => 'id_usuario', 
            'nome'        => 'nome', 
            'codigo'      => 'codigo', 
            'perfil'      => 'perfil', 
            'endereco'    => 'endereco', 
            'numero'      => 'numero', 
            'complemento' => 'complemento', 
            'observacao'  => 'observacao', 
            'telefone'    => 'telefone', 
            'data_visita' => 'data_visita', 
            'status'      => 'status'
        );
    }

    public function getSource() 
    {
        return 'domicilios';
    }
}

Check the getSource functions and what it returns.

I tried using getSource, but it's not working :(

This is my table: http://prntscr.com/2i3uvq

@webpositiva This is really weird. Please send me an email at [email protected] so that we can do a hangout and diagnose this. I am in US/Easter time.

Syntax error, unexpected EOF.... EOF STANDS FOR END OF FILE. SO HAVE A LOOK AT YOUR BRACKETS ETCC

This happens when parameters passed to a query are null.

Maybe phalcon can throw a understandable exception when that happens