Xavier Robin wrote:
Hello all,

I'm sorry if it is the wrong list, but I thought it was more a Catalyst-specific issue than a DBIx::Class one, as it is about the way Catalyst uses DBIx::Class.

I would like to use transactions in Catalyst.

my $transaction = $c->model('MyAppDB')->storage;
$transaction->txn_begin;
eval {
    # Do some insertions with $c->model('MyAppDB::Table')->create()
};
if ($@) {
    $transaction->txn_rollback;
}
else {
    $transaction->txn_commit;
}



$c->model('MyAppDB')->txn_do(sub {
  # Do some insertions here....
});


That will handle rollback/commit for you - I've never noticed any problems, but them I've not done much multiuser testing yet.

Ash

_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to