[eluser]WanWizard[/eluser]
That is not really a solution.
The query() method is used for hand-coded queries, which, unless you screened your parameters very carefully and properly escaped them all, just increased the chance on a sql injection.
Find the fault, and fix it. You still haven't shown us the code, or the query.
My educated guess is when $page = 0, your row indicator becomes negative (the -5). So it's a logic error you need to fix.