use DBIx::Class::ClassResolver::PassThrough;
use DBI;
-*dbi_commit = \&tx_commit;
-*dbi_rollback = \&tx_rollback;
+*dbi_commit = \&txn_commit;
+*dbi_rollback = \&txn_rollback;
=head1 NAME
$class->storage($storage);
}
-=head2 tx_begin
+=head2 txn_begin
Begins a transaction (does nothing if AutoCommit is off).
=cut
-sub tx_begin { $_[0]->storage->tx_begin }
+sub txn_begin { $_[0]->storage->txn_begin }
-=head2 tx_commit
+=head2 txn_commit
Commits the current transaction.
=cut
-sub tx_commit { $_[0]->storage->tx_commit }
+sub txn_commit { $_[0]->storage->txn_commit }
-=head2 tx_rollback
+=head2 txn_rollback
Rolls back the current transaction.
=cut
-sub tx_rollback { $_[0]->storage->tx_rollback }
+sub txn_rollback { $_[0]->storage->txn_rollback }
sub resolve_class { return shift->class_resolver->class(@_); }
my $obj = Genus->find(12);
eval {
- MyDB->tx_begin;
+ MyDB->txn_begin;
$obj->add_to_species({ name => 'troglodyte' });
$obj->wings(2);
$obj->update;
cromulate($obj); # can have a nested transation
- MyDB->tx_commit;
+ MyDB->txn_commit;
};
- if ($@) { eval { MyDB->tx_rollback } } # rollback might fail, too
+ if ($@) { eval { MyDB->txn_rollback } } # rollback might fail, too
Currently, a nested commit will do nothing and a nested rollback will die.
The code at each level must be sure to call rollback in the case of an error,
return DBI->connect(@info);
}
-=head2 tx_begin
+=head2 txn_begin
Calls begin_work on the current dbh.
=cut
-sub tx_begin {
+sub txn_begin {
$_[0]->dbh->begin_work if $TRANSACTION++ == 0 and $_[0]->dbh->{AutoCommit};
}
-=head2 tx_commit
+=head2 txn_commit
Issues a commit against the current dbh.
=cut
-sub tx_commit {
+sub txn_commit {
if ($TRANSACTION == 0) {
$_[0]->dbh->commit;
}
}
}
-=head2 tx_rollback
+=head2 txn_rollback
Issues a rollback against the current dbh.
=cut
-sub tx_rollback {
+sub txn_rollback {
if ($TRANSACTION == 0) {
$_[0]->dbh->rollback;
}