Go faster:
def getValueByID(table, field, id):
return db[table][id][field]
which is a shourtcut for :
def getValueByID(table, field, id):
return db(db[table].id == id).select(limitby=(0,1),
orderby_on_limitby=False).first()[field]
2013/7/5 Remco K <[email protected]>
> Very nice! It's working for me like this:
>
> def getValueByID(table, field, id):
> return db(db[table].id == id).select().first()[field]
>
> Thanks Massimo!
>
> def dynamicQuery(table, field,** value):
> return db(db[table][field]id =**= value).select()
>
> Op vrijdag 5 juli 2013 12:56:16 UTC+2 schreef Remco K het volgende:
>
>> Hi all,
>>
>> I have a question:
>>
>> I want to create queries dynamically:
>>
>> def dynamicQuery(table, field, value):
>> return db([table][field] == [value]).select()
>>
>> dynamicQuery('tableName', 'fieldName', 'value')
>>
>> Is there someone who can tell me how I can achieve this?
>>
>> Thanks in advance!
>> Remco
>>
> --
>
> ---
> 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 [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.