Let's add an ID field so we can more effectively query!

master
Silverwizard 10 years ago
parent 7359f2338c
commit 6976fd74da
  1. 2
      config.rb
  2. 2
      roller.rb

@ -10,5 +10,5 @@ password = gets
print "dbname: " print "dbname: "
dbname = gets dbname = gets
config.print("begin\nraise 'DB Error' unless $my = Mysql.connect('" + hostname.strip + "', '" + username.strip + "', '" + password.strip + "', '" + dbname.strip + "')\n") config.print("begin\nraise 'DB Error' unless $my = Mysql.connect('" + hostname.strip + "', '" + username.strip + "', '" + password.strip + "', '" + dbname.strip + "')\n")
config.print("unless $my.list_tables.include?('rolls')\nstatement = $my.prepare('CREATE TABLE rolls (id INT, roll TEXT, result TEXT, user TEXT, game TEXT)');\nstatement.execute\nend\n") config.print("unless $my.list_tables.include?('rolls')\nstatement = $my.prepare('CREATE TABLE rolls (id INT NOT NULL AUTO_INCREMENT, roll TEXT, result TEXT, user TEXT, game TEXT)');\nstatement.execute\nend\n")
config.print("rescue\nprint 'Please double check db settings or contact the administrator'\nend") config.print("rescue\nprint 'Please double check db settings or contact the administrator'\nend")

@ -4,7 +4,7 @@ require "./die"
require "cgi" require "cgi"
cgi = CGI.new cgi = CGI.new
result = roll(cgi.params["rollstring"][0].to_s) result = roll(cgi.params["rollstring"][0].to_s)
statement = $my.prepare("INSERT INTO rolls (id, roll, result, user, game) VALUES (" + $my.insert_id.to_s + ", '" + cgi.params["rollstring"][0] + "', '" + result.to_s + "', '" + cgi.params["user"][0] + "', '" + cgi.params["game"][0] + "');") statement = $my.prepare("INSERT INTO rolls (roll, result, user, game) VALUES ('" + cgi.params["rollstring"][0] + "', '" + result.to_s + "', '" + cgi.params["user"][0] + "', '" + cgi.params["game"][0] + "');")
statement.execute statement.execute
puts result puts result
$my.close $my.close

Loading…
Cancel
Save