[web2py] Re: How do I get last n rows from table?

2013-01-07 Thread Niphlod
tb = db.value
db((tb.gid == 'something')  (tb.sid == 'othersomething')).select(orderby=~
tb.updated, limitby=(0, 10))

will give you the last 10

On Monday, January 7, 2013 10:20:06 AM UTC+1, Hans Cr wrote:

 I want my controller to return the last ('updated') n rows given de 
 definition below given a certain 'gid' and 'sid'. Can anyone help me?

 Thanks a lot in advance!

 Hans


 db.define_table('value',
 Field('gid', 'string'),
 Field('sid', 'string'),
 Field('value', 'integer', required=True),
 Field('updated', 'datetime', default=request.now, writable=False, 
 readable=False),
 format = '%(value)s')


-- 





[web2py] Re: How do I get last n rows from table?

2013-01-07 Thread Hans Cr
Thanks! Works great!

On Monday, January 7, 2013 12:33:19 PM UTC+1, Niphlod wrote:

 tb = db.value
 db((tb.gid == 'something')  (tb.sid == 'othersomething')).select(orderby
 =~tb.updated, limitby=(0, 10))

 will give you the last 10

 On Monday, January 7, 2013 10:20:06 AM UTC+1, Hans Cr wrote:

 I want my controller to return the last ('updated') n rows given de 
 definition below given a certain 'gid' and 'sid'. Can anyone help me?

 Thanks a lot in advance!

 Hans


 db.define_table('value',
 Field('gid', 'string'),
 Field('sid', 'string'),
 Field('value', 'integer', required=True),
 Field('updated', 'datetime', default=request.now, writable=False, 
 readable=False),
 format = '%(value)s')



--