so if you are not interested delete please.
i’m sitting contemplating my options, checking out mysql-ruby or going
back to waiting tables. The abstraction(of dbi) is not important really.
So i start messing with mysql-ruby…
Check this file out…
begin
require "mysql"
require 'cgi’
cgi = CGI.new
cgi.header(‘content-type’=>‘text/html’)
sql = "SELECT * from tewt"
m = Mysql.new(‘localhost’, ‘me’, 'pwd,‘dev’)
res = m.query(sql)
printf “%d rows were returned\n
”, res.num_rows
res.each do |row|
printf “%s, %s\n
”, row[0], row[1]
end
res.free
res = m.query(sql)
printf “%d rows were returned\n”, res.num_rows
#dies here, Null Pointer given
res.each_hash do |row|
printf “%s, %s\n”, row[“id”], row[“df”]
end
res.free
rescue Exception
puts $!.to_s + '<p/>' + $@.join('<br/>')
ensure
m.close
end
···
here is the output
2 rows were returned
1, 1
2, 2
2 rows were returned NULL pointer given
/www/mytinerary/mysql.rbx:30:in each_hash' /www/mytinerary/mysql.rbx:30 /usr/local/lib/ruby/1.8/apache/ruby-run.rb:53:in
load’
/usr/local/lib/ruby/1.8/apache/ruby-run.rb:53:in `handler’
So it seems hashes might be a problem? As per this thread…
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/82892
Perhaps the same problem, as accessed through dbi causes this to hang,
me thinks, hopes
Anyone find out if that was a bug - or am i doing something else wrong…
Meanwhile, i think i’ll check out ruby on rails…seems cool.
peace,paul