Oh, I forgot to mention that I already tried the following: I slpit up the query in several parts and wanted to merge them back together but it seems that you cant merge them back together.
My code there was like: query_1='db(db.events.status==request.vars.status)' query_2='(db.events.severity==request.vars.severity)' query_3='.select(orderby=~db.events.datetime_submitted)' rows = query_1+query_2+query_3 The only result I got back was the merged string and not the query :-) On 21 Okt., 01:28, Sebastian Brandt <[email protected]> wrote: > Hi everyone, > > I am trying to create a dynamic SQL Query. > I have a form where a user can input several fields. I want to perfom > a query whether a user has filled out all fields or not. > > Got the following code: > > if not request.vars.message: > request.vars.message='' > if not request.vars.host: > request.vars.host='' > rows=db(db.events.host==request.vars.host) > (db.events.message==request.vars.message) > (db.events.severity==request.vars.severity) > (db.events.status==request.vars.status)(db.events.status==db.status.id) > (db.events.severity==db.severity.id).select > (orderby=~db.events.datetime_submitted) > form=SQLFORM(db.events) > return dict(form=form,rows=rows) > > If message and/or host are empty I get an empty query. Can I avoid > this anyhow or do I have to code a huge if-else-thingy to get my > result? :-) > > Greetings > > Sebastian Brandt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

