It would be form.vars.search, but don't construct a raw SQL statement like 
that using user input, as you will be open to a SQL injection attack.

Anthony

On Thursday, February 4, 2016 at 10:00:41 AM UTC-5, Imre wrote:
>
> AttributeError: 'SQLFORM' object has no attribute 'search'
>
>
> 2016. február 1., hétfő 18:49:20 UTC+1 időpontban Alfonso Serra a 
> következőt írta:
>>
>> I want to make a form which can search in  multiple db tables. The tables 
>>> has a same structure.
>>>
>>  
>> the form is only one since your inputs are a single search field isnt it?
>>
>> so what you would do is:
>>
>> form = SQLFORM.factory(Field("search", "string", notnull=True)).process()
>> results = []
>> if form.accepted:
>>    results = db.executesql("SELECT field1 as searchfield FROM table1 
>> UNION SELECT field2 from table2 WHERE searchfield LIKE %" + form.search + 
>> "%";)    
>>
>>
>>
>>  
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to