SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 122 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

If you give the option the Boolean true, the locking statement will default to
FOR UPDATE. For example, the following statement
Account.find 3, :lock => true
will result in this SQL statement, with the row for the account with an ID of 3 locked for updating:
SELECT * FROM accounts WHERE id=3 FOR UPDATE
And this Active Record code
Account.find 3, :lock => "LOCK IN SHARE MODE"
will result in the following SQL statement, with the row for the account with the ID of 3 locked
in share mode:
SELECT * FROM accounts WHERE id=3 LOCK IN SHARE MODE
You can also use the instance method lock!, which will reload your row with locking for
just that row. For example, the following method call
my_account = Account.find 3
my_account.lock!
results in the following SQL statements:
SELECT * FROM accounts WHERE id=3
SELECT * FROM accounts WHERE id=3 FOR UPDATE
CRUD Isn??™t Cruddy
Now that you??™ve explored how Active Record relates to the underlying SQL statements it creates,
you have a better appreciation for the power of Active Record, as well a more complete
understanding of what Active Record does and how it works.


Pages:
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6