vendredi 24 avril 2015

What's the simplest method in Ruby of telling if SQLite returned a row?

I am very new to Ruby and I am using it with SQLite.

I have written register and deregister functions but I am stuck writing a function to tell if a given user is registered in the database.

This is the current code:

 def registered?(l)
  db = SQLite3::Database.new "database.db"
  db.execute("SELECT user FROM t1 WHERE user = ?, ", l[1])
  end

What is the simplest method to tell if SQLite returned a row to this query?

Aucun commentaire:

Enregistrer un commentaire