We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Search function


The link above is my code for GET search function . The search is performed well for the first time, but when I clicked on the ''next page'' button, the results are wrong and different than what was on the first page.

Can somebody please point me what am I doing wrong?



So the problem is that in the second page you are getting different items than in the first one? That's how you use pagination (because you are doing that, isn't it?)


Exactly. The items on second page are different


Also it's value? From the Phalcon documentation (https://docs.phalcon.io/es/latest/reference/pagination.html#data-pagination):

The process of pagination takes place when we need to present big groups of arbitrary data gradually. Phalcon\Paginator offers a fast and convenient way to split these sets of data browsable pages.

I don't see what's the problem. You take a range of results to present on the view, nothing more.

edited Sep '14

Solved the following way:

//  objects/index action     
$this->persistent->objects = NULL;

//  objects/search action     
if (!$this->persistent->objects) {
    $query = Criteria::fromInput($this->di, 'Objects', $array);
    $parameters = $query->getParams();

    $objects = Objects::find($parameters);
    $this->persistent->objects = $objects;

if ($this->persistent->objects) {
    $objects = $this->persistent->objects;