Sorry for the somewhat long title, but I messed a bit with DBI in Ruby today, and I had some problems with prepared statements, as DBI quotes everything. I wanted to do something like the following:
sth = dbh.prepare(“UPDATE table SET ? = ? WHERE id = ‘1’”)
With a normal approach, both values would be quoted if I ran sth.execute(“field”, “value”), but as the sth.execute runs a quote function, which is just an ugly while loop, and the else part of it, is just value.to_s, you can do it quite smart:
sth.execute(:field, “value”)
Isn’t that nice? I think so.
Hi! I was surfing and found your blog post… nice! I love your blog. 🙂 Cheers! Sandra. R.