sql = db
-- if tag :
  sql = sql(db.mytable.tag = "xxx")
-- if status:
  sql = sql(db.mytable.status = "xxx")

result = sql.select()

On Fri, Feb 10, 2012 at 2:25 PM, Anthony <abasta...@gmail.com> wrote:

> You could do something like:
>
> query = db.mytable.id > 0
> if tag:
>     query &= db.mytable.tag == tag
> if status:
>     query &= db.mytable.status == status
>
> Anthony
>
>
> On Friday, February 10, 2012 5:10:01 PM UTC-5, gbs wrote:
>>
>> Hi,
>>
>> i have search posts on this group, but i don't have found the solution
>> of my question :$
>>
>> I have a table, wich display record of a database, nothing weird..
>>
>> I have made a form, so you can "filter" the result.
>>
>> You can check "Tag" of the record, "Status" of the record, so on...
>>
>> How can i create an sql "requete/statement" : ??
>>
>> sql = ""
>> -- if tag :
>>    sql += "tag = xxx"
>> -- if status:
>>    sql += " and status = xxx"
>>
>> result = db(sql).select()
>>
>> it's just an example, wich don't work, but i don't understand how to
>> chain condition of a query :$
>>
>> Best regards
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com

Reply via email to