Hi i have 3 tables product, produtType, inventory
productType have the default id, name and description Product have the default id productType, price, quantity invetory have the default id, name, location, products So i want to find a product, but i dont remember the exact name of it. So i go to the searcher and put something like "arro" the code has to find all the ocurrencies of "arro" in the database. So if a have "carrot" in the table product, and in the inventory i should see the two of us. and i can see Product -> 2 - Carrot - vegetable Inventory -> 5 - Charlie - Los Angeles - Carrot this should be a list of all the word with "arro" in all the tables in the database. I hope you can understand my problem, if not you could ask me so i can explain it again. The code i want to implement is above, i think im getting the data, the problem is i cant show it. I would apprecaite a lot if you could help me with this. Thanks in advance -- Kyo On Oct 28, 1:44 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > It does not. > > can you make a concrete example of data and what you expect in the > output? > > Massimo > > On Oct 28, 1:13 pm, __Kyo__ <iacastil...@gmail.com> wrote: > > > > > Thanks, it will be very helpful, but how can i solve the initial > > problem? > > > On Oct 28, 11:21 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > Do not use exec: > > > > exec('selected=[db.%s.fields]' % (i)) #The list of the > > > > rewrite as > > > > selected = db[i].fields > > > > This > > > > exec('datos=[m.id for m in db().select(db.%s.ALL) > > > if string.lower(str(request.vars.dato))\ > > > in string.lower(str(m.%s))]' % (i, j[x])) #get the > > > > rewrite as > > > > datos=[m.id for m in db().select(db[i].ALL) > > > if string.lower(str(request.vars.dato))\ > > > in string.lower(str(m[x]))] > > > > And this: > > > > exec('lista=db(db.%s.id.belongs(datos)).select()' % (i)) > > > > rewrite as > > > > lista = db(db[i].id.belongs(datos)).select() > > > > will make your code much faster. > > > > On Oct 28, 10:52 am, __Kyo__ <iacastil...@gmail.com> wrote: > > > > > Hi everyone, i have to make a searcher, i have to put in my input a > > > > letter like "a" and then i want to search this letter in all the > > > > tables that are in the database. i made this code, but the problem i > > > > have in the moment i have to show or capture the solution. Could you > > > > please help me with this? > > > > > if not session.incidente: redirect(URL > > > > (r=request,c='default',f='login')) > > > > import string; > > > > def index(): > > > > lista=[] > > > > headers=[] > > > > tabla=db.tables #The list of the name of the table > > > > resultado=[] > > > > if request.vars.boton: > > > > for i in tabla: > > > > exec('selected=[db.%s.fields]' % (i)) #The list of the > > > > names of all the fields in the table > > > > for j in selected: > > > > for x in range (len(j)): > > > > exec('datos=[m.id for m in db().select(db.%s.ALL) > > > > \ > > > > if string.lower(str(request.vars.dato))\ > > > > in string.lower(str(m.%s))]' % (i, j[x])) #get the > > > > ids of the fields in the table > > > > exec('lista=db(db.%s.id.belongs(datos)).select()' % > > > > (i)) > > > > headers=dict([(c,db[c.split('.')[0]][c.split('.') > > > > [1]].label) for c in lista.colnames]) > > > > #Here is the problem, because it dont show the result. > > > > return dict(tabla = tabla, lista=lista, headers=headers) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---