[Zope-DB] Z sql Method and using 'OR'
charlie at begeistert.org
Wed May 5 17:07:50 EDT 2004
Eek! This is one of the reasons I really don't like DTML this is essentially
duplicating SQL functionality with a lot of impenetrable syntax making
debugging more difficult because SQL is going to be generated.
On 2004-05-05 at 21:39:57 [+0200], Kent Hoxsey wrote:
> The ZSQL method would have two input parameters, 'username'
> and 'useroffice', and would look like this:
> select * from users u
> <dtml-sqlgroup where> u.user_id = u.user_id
> <dtml-if username>
> <dtml-sqltest username column="u.username" type="string" optional="Yes">
> <dtml-if useroffice>
> <dtml-sqltest useroffice column="u.useroffice" type="string" optional="Yes">
> I know this is a bit complicated and messy, but that's due to ZSQL methods
> using DTML to dynamically define the SQL (switch ZSQL to PageTemplates
> and TAL? we'll save that discussion for another time...) . Stick with me
> and I'll break it down...
I think a good compromise can be achieved like this:
select * from users
(username = <dtml-sqlvar name="username" type="string">
useroffice = <dtml-sqlvar name="useroffice" type="string">
I've got so used to this I haven't even started looking at SQLs own approach
to flow control...
Now, this only works for either "username" OR "useroffice" but will give a
syntax error if both are passed. There is an elegant solution to this
More information about the Zope-DB