water has asked for the wisdom of the Perl Monks concerning the following question:
Can some explain this linesub do_transaction { my $class = shift; my ( $code ) = @_; # Turn off AutoCommit for this scope. # A commit will occur at the exit of this block automa +tically, # when the local AutoCommit goes out of scope. local $class->db_Main->{ AutoCommit }; # Execute the required code inside the transaction. eval { $code->() }; if ( $@ ) { my $commit_error = $@; eval { $class->dbi_rollback }; # might also di +e! die $commit_error; } }
Is this a set statement? The DBI docs mention settinglocal $class->db_Main->{ AutoCommit };
to turn on txns, but clearly the local statement in the routine above doesn't have the =0. What is this local statement doing?$dbh->{AutoCommit} = 0
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Seeking clarification on 'local' in Class::DBI txn code
by etcshadow (Priest) on Mar 21, 2004 at 21:24 UTC | |
|
perldoc -f local
by Anonymous Monk on Mar 21, 2004 at 14:12 UTC | |
by Happy-the-monk (Canon) on Mar 21, 2004 at 14:30 UTC | |
by ysth (Canon) on Mar 21, 2004 at 21:10 UTC |