Hey!
I’m creating my own little database class, that I’m gonna use in some
school assignments. I can not use Activerecord for this
I require the ‘mysql’ gem in my class.
I would like to create a method for inserting a row(s) in a specific
table. Here is my method:
def insert_row(table, params = {})
col = params.keys
result = params.values
@db.query(“INSERT INTO #{table} (#{col}) VALUES(#{result});”)
end
Almost as expected I get this error:
You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near ‘[:name,
:email]) VALUES([“Anders”, "[email protected]])’ at line 1.
So my question is. How can I parse a hash into mysql?