[triangle-zpug] SQL search

Charles Fulton triangle-zpug@starship.python.net
Fri, 9 Aug 2002 10:50:23 -0400


never mind... on further consideration I figured out a decent way to go
about it (I had missed the column= parameter in the docs.  Didn't work so
well when mysql was looking for a column named expr="...  : )

anyway, this is what I did:

  <dtml-sqlgroup where>
    <dtml-sqltest papertype op=eq type=nb optional>
    <dtml-and>
      <dtml-sqltest expr="searchWildcard(author)" column=author op=like
type=nb optional>
    <dtml-and>
      <dtml-sqltest expr="searchWildcard(title)" column=title op=like
type=nb optional>
  </dtml-sqlgroup>


where searchWildcard is:

  if len(searchparam) != 0:
    return '%'+searchparam+'%'
  return searchparam