浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

还想请教一下update users set a=1 where id in (1,2,3)这句在rails中该如何写呢

   云(11753503)  18:31:29
                ActiveRecord::Base.connection.execute(str)

[上海] Jerry(40578681)  18:34:38
人家要rails的写法
[上海] Jerry(40578681)  18:35:08
User.update_all({:a => 1}, :id => [1,2,3])
[上海] Jerry(40578681)  18:35:24
User.update_all({:a => 1}, {:id => [1,2,3]})
   云(11753503)  18:35:55
你这样写sql中update有几条?
[上海] Jerry(40578681)  18:36:36
1
[上海] Jerry(40578681)  18:36:45
>> Proposal.update_all({:user_id => 1}, :id => [1,2])
[上海] Jerry(40578681)  18:36:56
AREL (1.4ms)  UPDATE "proposals" SET "user_id" = 1 WHERE ("proposals"."id" IN (1, 2))

posted on 2011-01-31 19:49  lexus  阅读(712)  评论(0编辑  收藏  举报