Reputation: 51
Previously I used
Model.create()
to insert a row, now, I want to use DELAYED option in Mysql.
But, if I write
ActiveRecord::Base.connection.execute("INSERT DELAYED INTO `TABLE` (`row`) VALUES (#{params[:id]})")
so I get sql injection. How to prevent it?
Upvotes: 0
Views: 226
Reputation: 222428
Use connection.quote
id = ActiveRecord::Base.connection.quote(params[:id])
ActiveRecord::Base.connection.execute("INSERT DELAYED INTO `TABLE` (`row`) VALUES (#{id})")
Upvotes: 2