Paging all paging code!

Blog post

Author
Message

Rocket Man
Posts: 383
Posted on: 2012-10-16 17:58:41.000
Paging code is really easy in SQLite. You do a SELECT statement as normally but add the LIMIT clause with two numbers separated by a comma. The first number is the offset, aka where you start from, and the second number is the number of results you want back. So if you wanted ten results starting from the thirtieth, you just SELECT ... LIMIT 30,10 and that's it!

Displaying the current paging links is something I might want to do a lot, so I made a function in Rockets to do it. The function works like this:

(display-paging-links int-start-page int-total-pages int-current-page str-page-url)

So to display the top ten pages you'd call (display-paging-links 1 10 1 "rockets-main").

Neat and easy!


Views: 4698