[Zope-DB] zsql optional parameters from a form

David Salgado david at digitalronin.com
Fri Apr 1 07:01:48 EST 2005


Hi there

I've got a form with an input text box called 'msisdn', and a ZSQL query 
like this;

<dtml-comment>
title: test
arguments: msisdn
connection_id: mydbconn
</dtml-comment>
select * from mytable
<dtml-sqlgroup where>
   <dtml-sqltest msisdn op=eq type=string optional>
</dtml-sqlgroup>

This works fine if I supply a MSISDN in the text box - I get the records 
I expect. But, if I leave msisdn blank, then from the trace log I can 
see that the query that gets sent to the mysql database is "select * 
from mytable where msisdn='' ", and so I get no records when what I want 
is ALL the records.

My optional 'msisdn' parameter is always being supplied, even if I leave 
the text box empty. Is there any way I can prevent this from happening?

Eventually, I want to have a form with lots of fields to specify a 
variety of criteria, but if blank text boxes are always coming through 
as empty strings, it's not going to work.

Thanks in advance for any help.

David



More information about the Zope-DB mailing list