K
keinlezard
hello
My problem is
I have this code in a file
And in another file I have something like
I try to get the dbh handler because I need to write a function that use
it ... may be I'm wrong and it exits another way to do this
My funtion is something like that
def List(some parameters)
query_tab_mater="select id, label from sparc.type_materiel order by
label asc"
sth=dbh.execute(query_tab_mater)
sth.fetch{|k,v|
output+="<option value='#{v}'"
type_materiel = 'non-connu'
if v == type_materiel
output+= " selected='selected'"
end
output+= ">#{v}</option>"
}
output+= "</select></td></tr> "
end
but at excecution time ruby complain about dbh not known
can somebody help me and explain it
thank you
My problem is
I have this code in a file
module DB_parc
Toto=2
def DB_parc::session()
begin
dbh = DBI.connect(CONF_parc:b,CONF_parc::User,CONF_parc:assword);
#backend = Backend.new(dbh)
#yield(backend)
# yield rovoque l'execution de la variable passée en parametre
yield(dbh)
rescue DBI::Error => e
puts "#{e.errstr}"
ensure
dbh.disconnect if dbh
end
end
end
And in another file I have something like
DB_parc.session{|dbh|
schema="sparc"
.... }
I try to get the dbh handler because I need to write a function that use
it ... may be I'm wrong and it exits another way to do this
My funtion is something like that
def List(some parameters)
query_tab_mater="select id, label from sparc.type_materiel order by
label asc"
sth=dbh.execute(query_tab_mater)
sth.fetch{|k,v|
output+="<option value='#{v}'"
type_materiel = 'non-connu'
if v == type_materiel
output+= " selected='selected'"
end
output+= ">#{v}</option>"
}
output+= "</select></td></tr> "
end
but at excecution time ruby complain about dbh not known
can somebody help me and explain it
thank you