cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[NFR] Paginator page

Open lantian opened this issue 13 years ago • 2 comments

$currentPage = $this->request->getQuery('page', 'int', 1);

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

If $currentPage < 1 it throws and exception... it's good, but this engenders new 'if' that will check this condition in every controller - this is annoying... this is small... but it would be great if

if ($currentPage < 1) $currentPage = 1; 

...check was inside paginator. Thanks.

lantian avatar Feb 15 '13 16:02 lantian

I think throwing an exception is the correct behavior.

If you don't care about negative values the best solution would be

$currentPage = max(1, $this->request->getQuery('page', 'int', 1));

But I think you should send 404 error in such cases.

iforp avatar Mar 21 '13 12:03 iforp

This is implemented in 1.1.0

ghost avatar May 03 '13 04:05 ghost