[Zope] ZSQL "OR" search help

Dieter Maurer dieter@handshake.de
Mon, 16 Jul 2001 20:16:41 +0200 (CEST)


Fabrizio writes:
 > How can I perform a "OR" search on a SQL database field using a web form ?
 > ...
 > Thanks for your help.
Hmm....

What have you already looked at?

  *  an SQL description?
  *  the DTML reference?
  *  the Zope book?
  *  the HTML spec or a book about HTML?
  *  URL:http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html

I think, you should look at some of them. I would call that
doing your homework...

Some hints:

  *  you need to decide how to collect the OR operands on the
     web page. Options:

       -  a multiple selection (be sure to add ":list" to the select name)
       -  a textarea with a ":lines" suffix
       -  an input field with the ':tokens' suffix
       -  a string with 'OR' operators

     With the exception of the last option, all will give you a list.
     For the last option, you must parse the string into a list.
     If things are simple, you could use "string.split".

  *  you now have a list of search terms.
     The best way to use it in the SQL statement would
     probably be "dtml-sqltest multiple".
     See the DTML reference for details

  *  you will need a Z SQL Method and a Database adapter.
     Thinks, you learn in the Zope book.
  

Be seeing you after your homework with more concrete questions....


Dieter