Hi all......
please give me an example that use SQL in models to handel data in the data base. with "sql.execute" or any other possible way..
thankx
Hi all......
please give me an example that use SQL in models to handel data in the data base. with "sql.execute" or any other possible way..
thankx
class Model < ActiveRecord::Base def raw_sql_query connection.execute("select name from #{table_name}") end end
The above example will return something like this: [{:name => "A"}, {:name => "B"}]
thankx Andrew
I’ll try it