Method: WIKK::SQL#transaction
- Defined in:
- lib/wikk_sql.rb
#transaction {|[]| ... } ⇒ Object
Perform a transaction in the passed block. RollBACK on error, otherwise COMMIT
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/wikk_sql.rb', line 92 def transaction puts "transaction" if block_given? begin @my.query("START TRANSACTION WITH CONSISTENT SNAPSHOT") yield #Start executing the query black. @my.query("COMMIT") rescue Mysql::Error => e @my.query("ROLLBACK") raise e end end end |