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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---