Correct "currentPage" higher than "pages"

There where a little bug in my previous "fix" to avoid currentPage be higher than pages total.

When total of pages is zero the query offset becomes negative causing SQL error.