Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Database Query
Jeff Miller
3/14/2008 1:49:00 AM
Hello,
This may sound silly, but I can't seem to get my results out of a
database query. I can do this fine in Ruby on Rails, but from a Ruby
script, I can't seem to. I know my query works because I've already
tested it. My code is as follows:
require 'mysql'
create_log = File.new("comparison_imei.html", "w")
db = Mysql.connect("localhost", "root", "root", "compare_imei")
@num_perfect_matches = db.query("
SELECT COUNT(*) AS n
FROM att
JOIN bes
ON att.att_imei = bes.bes_imei
ORDER BY
att.att_name")
for num in @num_perfect_matches
@numberofrows = num['n']
create_log.puts @numberofrows
end
This gives me the following error:
compare_imei.rb:22: undefined method `each' for nil:NilClass
(NoMethodError)
Is there a proper way to get data out of my query?
Thanks,
- Jeff Miller
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Database Query
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password