Why is this not correct. What is wrong with it??
#!/usr/bin/ruby
require "mysql"
class Game
attr_accessor :id, :name, :urlName, :description, :hits, :categorys, :width, :height, :nilGame
def load(id)
#Load mysql
begin
# connect to the MySQL server
con = Mysql.new('localhost', 'user', 'pass', 'database')
rescue Mysql::Error => e
puts "mysql error"
ensure
# disconnect from server
con.close if con
end
rs = con.query("select * from games where id='#{id}' limit 1")
rs.each_hash do |row|
if row['id'].nil
@nilGame = true
else
@id = id
@name = row['name']
@urlName = row['urlname']
@description = row['description']
@hits = row['hits']
@categorys = row['categorys']
@width = row['width']
@height = row['height']
end
end
con.close
end
end