Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Search function

http://pastebin.com/dCw1HYB7

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?

Thanks



19.9k

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?)



11.0k

Exactly. The items on second page are different



19.9k

Also it's value? From the Phalcon documentation (http://docs.phalconphp.com/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.



11.0k
Accepted
answer
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;
}