`
zfj.rails
  • 浏览: 44832 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Table.update_all也可以用:conditions

阅读更多

文档:

update_all(updates, conditions = nil, options = {}) 




例子:

Billing.update_all( "author = 'David'", "title LIKE '%Rails%'" )
/*
mysql > update billings set author = 'David' where title LIKE '%Rails%';
*/


也可以这样写:
author = 'David'
title = 'Rails'
Billing.update_all(["author = ?", author], ["title like ?", "%#{title}%"])


也是可以传变量的喔。这样写安全些。
分享到:
评论

相关推荐

    Software Testing and Continuous Quality Improvement

    Software Testing and Continuous Quality Improvement <br>SECTION I SOFTWARE QUALITY IN PERSPECTIVE . . . . . . . . . . . . . . . 1 1 Quality Assurance Framework. . . . . . . ........

    一个win32下的ARM开源编译器

    pre-UAL syntax does not specify the "s" (flag update) in the opcodes for arithmetic operations involving the low set of registers (r0-r7). For example: pre-UAL Syntax | UAL Syntax ;Note -----------...

    微软内部资料-SQL性能优化5

    A qualified operation is one that affects only specific rows that satisfy the conditions of a WHERE clause, as opposed to accessing the whole table. An index can have multiple node levels An index ...

    Delphi7.1 Update

    even when all of the details are deleted if the detail table was previously cloned (Quality Central 5646). * In some cases, records may disappear from a nested TClientDataset after performing edits, ...

    SQL语法大全

    用 rs("别名") 获取统的计值,其它函数运用同上。 (5) 数据表的建立和删除: CREATE TABLE 数据表名称(字段1 类型1(长度),字段2 类型2(长度) …… ) 例:CREATE TABLE tab01(name varchar(50),datetime default ...

    微软内部资料-SQL性能优化3

    Another type of table lock is a schema stability lock (Sch-S) and is compatible with all table locks except the schema modification lock (Sch-M). The schema modification lock (Sch-M) is incompatible ...

    Oracle sqldeveloper without jdk (win+linux)

    You may still update the column with an explicit UPDATE statement referencing the SQL UNISTR function. - Bug 4924518: Only the SQL Worksheet statement input area (code editor) uses a configurable ...

    DebuggingWithGDB 6.8-2008

    Table of Contents Summary of gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Free Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

    MySql存储过程编程.chm

    Tuning DML (INSERT, UPDATE, DELETE) Section 21.6. Conclusion Chapter 22. Optimizing Stored Program Code Section 22.1. Performance Characteristics of Stored Programs Section 22.2. How Fast Is ...

    SSD7 选择题。Multiple-Choice

    (b) the name of the table, the names of the table's attributes, the data types of the table's attributes, the formats of the table's attributes, and the maximum number of rows that the table can have...

    RxLib控件包内含RxGIF,全部源码及DEMO

    with the DisplayNames of all indexes available for the table it's assigned to. TBDEItems, TDatabaseItems, TTableItems are lists populated by the corresponding BDE information (database list, table ...

    k7 SRIO参考例程

    Core name: Xilinx LogiCORE Serial RapidIO Version: 5.5 ... - Switch Route Table Destination ID Limit CAR (offset 0x34) - Core does not have functionality to enable the user to drop...

    Radmin自动登录器v3.0-多国语言绿色版-Release1-20150615

    使用前请将Radmin Viewer 3.5的Radmin.exe文件直接拷贝到该目录中,其它Radmin Viewer 3.x版本也可以,中文版、英文版均可; 请设置防火墙允许Radmin.exe和RadminM.exe(仅扫描功能用)访问网络; 若要用到聊天、...

    MS-DOS 5.0

    4.2 All Computers Expanded-Memory Driver 4.3 Bus Master DMA Controller 4.4 HIMEM.SYS Location 4.5 INT15 Access to Extended Memory 4.6 Intel LIM Driver 4.7 Phoenix BIOS and HIMEM.SYS 4.8 QEMM ...

    rx第三方控件

    with the DisplayNames of all indexes available for the table it's assigned to. TBDEItems, TDatabaseItems, TTableItems are lists populated by the corresponding BDE information (database list, table ...

    Radmin自动登录器v3.0

    使用前请将Radmin Viewer 3.5的Radmin.exe文件直接拷贝到该目录中,其它Radmin Viewer 3.x版本也可以,中文版、英文版均可; 请设置防火墙允许Radmin.exe和RadminM.exe(仅扫描功能用)访问网络; 若要用到聊天、...

    Diskeeper 2008 v12.0.759.0

    performance analysis technology gets a full update and tight integration with Diskeeper Administrator抯 industry-pioneering performance management functionality. Now you can get real-time ...

    Microsoft Library MSDN4DOS.zip

    使用 DOSBOX 就可以运行此库。此库含一大古董级MS官方编程参考材料,主要针对 Windows 3.0 平台,真可谓之应用尽有: MS Windows 3.0 SDK Guide to Programming MS Windows 3.0 SDK Install. & Update Guide MS ...

Global site tag (gtag.js) - Google Analytics