On Sat, 2003-08-30 at 05:26, Brian Candler wrote:
> > By the way: I tried DBI but it seems not 1.8.0-ready ? I got a lot
> > of errors...
> 
> It works just fine for me. I get a couple of warnings only, no errors. I use
> DBI-0.0.20 with mysql, OCI8, sqlite

I, too, am running Ruby 1.8, DBI 0.0.20 (but with Postgresql) without
problems.

> mysql-ruby contains a class method:  Mysql.escape_string (alias Mysql.quote)
> which does exactly what you want.

Meino mentions later that he found a quote method.  I would just like to
remind folks that if you are using DBI, the quote method is part of the
driver and can be accessed via ...

   dbh = DBI.connect("DBI:yada:yada", "yada", nil)
   dbh.quote("N'Djamena")  # => "'N''Djamena'"

The DBI version /should/ take into account different quoting
requirements of the individual drivers (if it doesn't, that's a bug!). 
Explicit quoting isn't needed if you are using the "?" parameters (as
you should!).

-- 
-- Jim Weirich       jweirich / one.net      http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct, 
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)