Hello,

I may not understanding something... I am desapointed that I can't simply 
manipulate offset of the sql... Or should I just manipulate the limit...

I mean if I do repetitively thise query in sql :

select * form table order by desc limit 10 offset 0
select * form table order by desc limit 10 offset 10
select * form table order by desc limit 10 offset 20
select * form table order by desc limit 10 offset 30

I will get progressively all the records from the table 10 at a time...

But I can't simply do it with this query :

rows = db((db.table.id > 0)
              ).select(db.table.id, db.table.represent_field,
                       orderby=~db.table.id,
                       limitby=(10, offset if offset else 0))

Reading the book there seems to have planty of backend that don't support 
paging with limit and offset properly...

But still I find it frustrasting to have to struggle with the DAL and have 
to provide min and max for the offset to a limitby function which isn't a 
limit but an offset in reallity...

I solve it with this :

offset = request.vars.limit_by
if offset not in ('None', '', None) and offset.isdigit():
    offset = int(offset)
    min = offset - 10
    max = offset
else:
    offset = None
    min = 0
    max = 10

rows = db((db.table.id > 0)
              ).select(db.table.id, db.table.represent_field,
                       orderby=~db.table.id,
                       limitby=(min, max))


Richard


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to