From: Peter Rabbitson Date: Wed, 10 Mar 2010 08:34:37 +0000 (+0000) Subject: docpatch close RT52681 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a41641db1396900aa81c4ccd5adc8602ba3049ee;p=dbsrgits%2FDBIx-Class-Historic.git docpatch close RT52681 --- diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 16fa647..8b135ae 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -1217,6 +1217,8 @@ callback routine. =head1 TRANSACTIONS +=head2 Transactions with txn_do + As of version 0.04001, there is improved transaction support in L and L. Here is an example of the recommended way to use it: @@ -1248,11 +1250,16 @@ example of the recommended way to use it: deal_with_failed_transaction(); } +Note: by default C will re-run the coderef one more time if an +error occurs due to client disconnection (e.g. the server is bounced). +You need to make sure that your coderef can be invoked multiple times +without terrible side effects. + Nested transactions will work as expected. That is, only the outermost transaction will actually issue a commit to the $dbh, and a rollback at any level of any transaction will cause the entire nested transaction to fail. - + =head2 Nested transactions and auto-savepoints If savepoints are supported by your RDBMS, it is possible to achieve true @@ -1344,9 +1351,19 @@ commits are happening, but it works just the same as for plain L<>: If the C-block around C fails, a rollback is issued. If the C succeeds, the transaction is committed (or the savepoint released). -While you can get more fine-grained controll using C, C +While you can get more fine-grained control using C, C and C, it is strongly recommended to use C with coderefs. +=head2 Simple Transactions with DBIx::Class::Storage::TxnScopeGuard + +An easy way to use transactions is with +L. See L for an example. + +Note that unlike txn_do, TxnScopeGuard will only make sure the connection is +alive when issuing the C statement. I will not (and really can not) +retry if the server goes away mid-operations, unlike C. + =head1 SQL =head2 Creating Schemas From An Existing Database