在下文中,
@records = ActiveRecord::Base.connection.exec_query(sql)
字符串
“sql”字符串是对返回表的db函数的调用。
我可以做些什么来让@records成为一个ActiveRecord关系,这样我就可以使用典型的关系方法/语法,如
@records.each do |r| r.county, r.zip_code end
型
在下文中,
@records = ActiveRecord::Base.connection.exec_query(sql)
字符串
“sql”字符串是对返回表的db函数的调用。
我可以做些什么来让@records成为一个ActiveRecord关系,这样我就可以使用典型的关系方法/语法,如
@records.each do |r| r.county, r.zip_code end
型
1条答案
按热度按时间h9a6wy2h1#
这个类封装了在任何数据库连接适配器上调用
exec_query
返回的结果。例如:字符串