rails
jimcarol
微信号: h7113253
添加请注明来意
展开
-
actionrecord 连接多个数据库
有两种方法第一种: 每个model各自连接 # 建立一个数据库链接 example: ActiveRecord::Base.establish_connection( adapter: "mysql2", host: "localhost", username: "myuser", password: "mypass",原创 2017-01-06 18:08:00 · 339 阅读 · 0 评论 -
activerecord直接执行sql语句的写法ActiveRecord::Base.connection.execute
If the helpers provided by Active Record aren't enough you can use the execute method to execute arbitrary SQL: Product.connection.execute("UPDATE products SET price = 'free' WH原创 2017-01-06 18:24:42 · 2023 阅读 · 0 评论