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
-~----------~----~----~----~------~----~------~--~---

Reply via email to