Re: [web2py] Re: one select form multiple table

2016-02-16 Thread Richard Vézina
I think like this you make you union search without worry about SQL injection : results = db(db.table1.field1 == '%{0}%'.format(form.vars.search)).select(db.table1.field1.with_alias('searchfield')) | db(db.table2.field2 == '%{0}%'.format(form.vars.search)).select(db.table2.fiel

[web2py] Re: one select form multiple table

2016-02-16 Thread Alfonso Serra
executesql always return tuples and thats ok unless you need to to hide columns, remove elements, edit or add data and such. To turn a tuple into a list is just result = list(result) To return a table web2py has many "magic" methods like SQLFORM.grid or SQLFORM.smartgrid that will only work if

[web2py] Re: one select form multiple table

2016-02-16 Thread Imre
Thanks, it works but is tuple. How can I make a table from this records in view? 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 on

[web2py] Re: one select form multiple table

2016-02-04 Thread Anthony
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. febr

[web2py] Re: one select form multiple table

2016-02-04 Thread Imre
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

[web2py] Re: one select form multiple table

2016-02-01 Thread Alfonso Serra
> > 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 fo