On Feb 12, 2008, at 9:36 PM, Adrian Klaver wrote:

> This form has to to do with plants,
> so a search might be   "select  from plant1  where (i)like '%mint%'"  
> How is
> the best way to do this or can someone point me to an existing  
> example?

        Sound like you need a parameterized query. To do that, set the where  
clause with:

self.addWhere("myfield ilike '%%%s%%' ")

Note that the literal '%' have to be doubled up; the parameter place  
holder is the '%s' in the middle. Now override bizobj.getParams to  
return a tuple that contains a value for each of placeholders in your  
where clause. Note that if you do several addWhere calls with  
parameters in them, the order they are added determines the order of  
the values returned in the tuple from getParams(). In your example,  
assuming that the value 'mint' that you wanted in your query was in  
stored in an attribute named 'plantType', getParams() would look like:

def getParams(self):
        return (self.plantType, )

        Hope that helps,

-- Ed Leafe





_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]

Reply via email to