hi everyone. i have a problem with paginating my results. i guess i didn't understand the logic in limitby.
normally an sql query SELECT * FROM post LIMIT 2 OFFSET 0 displays the first 2 results. And I can get the first 2 records with db (db.post.id>0).select(limitby(0,2)). so limit is 2 and offset is 0. however the problem is, this query fails: db(db.post.id>0).select(limitby(2,2)). in this query the limit is 2 and the ofset is 2 either. however it doesn't return select * from post limit 2 offset 2 but it returns select * from post limit 0 offset 2 because in sql.py 2846 limit is lmax - lmin and offset is lmin. i have edited that line as sql_o += ' LIMIT %i OFFSET %i' % (lmax, lmin) and it is working as expected. now my pagination is working. here is my codes for pagination: perpage = 2 totalposts = db(db.post.id > 0).count() totalpages = totalposts / perpage page = int(request.vars.page) if request.vars.page else 1 limit = int(page - 1) * perpage posts = db(db.post.id > 0).select(orderby=~db.post.id, limitby=(limit, perpage)) please let me know if there's another page for doing this. sincerely Mengu --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---