N
ngw
Hi *,
I need to find out if a MySQL db contains a certain table, if not I have
to create it.
I'm using the SHOW TABLES instruction that returns a Mysql::Result
object, but after that I'm stuck, I don't know how to process the
resultset without writing awful code
I mean, I can resolve the problem by using a "state" variable inside a
block and turn it to true if it finds the table, but I guess there's a
more appropriate way to handle this kind of problems.
result = dbh.query("SELECT * FROM album")
foo = false
result.each {|row| foo = true if row.include?("Killing Joke")}
if foo == true
puts "HA!"
end
result.free
This is the code I have now, UGH !
TIA,
ngw
I need to find out if a MySQL db contains a certain table, if not I have
to create it.
I'm using the SHOW TABLES instruction that returns a Mysql::Result
object, but after that I'm stuck, I don't know how to process the
resultset without writing awful code
I mean, I can resolve the problem by using a "state" variable inside a
block and turn it to true if it finds the table, but I guess there's a
more appropriate way to handle this kind of problems.
result = dbh.query("SELECT * FROM album")
foo = false
result.each {|row| foo = true if row.include?("Killing Joke")}
if foo == true
puts "HA!"
end
result.free
This is the code I have now, UGH !
TIA,
ngw