[Dbix-class] how to implement Transactions (over different db
tables) in a Catalyst project
kakimoto at tpg.com.au
kakimoto at tpg.com.au
Mon Jul 6 02:43:37 GMT 2009
hi , everyone,
i m trying to put transactions in place for my catalyst project.
For example, I would like to create a new user subscription.
What this does is,
- create two new Address objects (Address db table) where one's for
billing address and another for main contact.
- create a new User Subscriptions object (and link the two new Address
objects by IDs into attributes, billing_address_id and
main_contact_address_id).
What I have refered to:
http://search.cpan.org/~ribasushi/DBIx-Class-0.08107/lib/DBIx/Class/Manual/Cookbook.pod
http://kobesearch.cpan.org/htdocs/DBIx-Class/DBIx/Class/Storage.html#txn_do
http://kobesearch.cpan.org/htdocs/DBIx-Class/DBIx/Class/Storage.html#txn_begin
http://kobesearch.cpan.org/htdocs/DBIx-Class/DBIx/Class/Storage.html#txn_commit
http://search.cpan.org/~ribasushi/DBIx-Class-0.08107/lib/DBIx/Class/Storage.pm
In the past, when I had to work with just DBI, I would manually start a
transaction and commit it at the end if no exceptions occur. In
the case of the latter, I will call a rollback.
How do I do it here in Catalyst/DbiX::Class land?
I tried to read up the
http://kobesearch.cpan.org/htdocs/DBIx-Class/DBIx/Class/Storage.html#txn_do
doc but I can't see how the example can apply to Catalyst.
It says, "$schema->txn_do($coderef)" to get the schema but in catalyst,
we access the
database tables directly. For example,
my $rs = $c->model('myAppDB::UserSusbcriptions')->search( .. );
I'm a bit confused and have looked in a few places. Can anyone please
educate me?
thank you:)
K.akimoto
More information about the DBIx-Class
mailing list