Diez:

What I am trying to do is have something like this:

Whereclause = ''
If parm1:
        Whereclause = x
If parm2:
        Whereclause = whereclause + y
If parm3:
        Whereclause = whereclause + z

Traditionally I have built my SQL statements by hand and just built the
where clause as needed, but now with SQLObject (which I know is MUCH better
than the way I was doing it) I haven't yet figured out how to dynamically
add to my where clause based on the parameters that were passed in my form.
Jorge sent a solution that I think will work.  I'm going to give it a run
now.

        -Jim

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Diez B. Roggisch
Sent: Friday, January 12, 2007 4:43 PM
To: [email protected]
Subject: [TurboGears] Re: Dynamic SQL Help


Jim Steil schrieb:
> Hi:
> 
>  
> 
> I'm trying to dynamically build an SQL statement, actually, just the 
> where clause.  I know I've seen sample of this using SQLObject 
> somewhere, but I can't find them again.  I seem to remember seeing 
> something about adding to a where clause.  Can someone help me find what 
> I'm looking for?  I'm happy to elaborate on my needs if what I've said 
> so far doesn't make enough sense.

You certainly should do that, yes.

Generally, its done like this:


ModelClass.select(ModelClass.q.property == value)


Diez





--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to