[CDBI] Transaction over parent and children has_a objects

Christopher H. Laco claco at chrislaco.com
Tue Aug 9 02:49:40 BST 2005


I'm at wits end with something that is simple in SQL, but apparently a 
pain the butt under CBDI.

All I'm really after is to turn autocommit off, update a parent and 
multiple child has_a record, them commit or rollback the entire 
transaction. Something like:

DBI->do('BEIGN TRANSACTION');

$artist->name('foo')
$artist->cds('CD1')->name('Bar');

DBI->do('COMMIT TRANSACTION');

My main problem is that normally, Artist and CD objects are 
autoupdate(1), but in this situation, I need the Artist all of the CDs 
to be autoupdate(0); without looping through them and setting them 
manually. [Of course $artist->autoupdate(0) can be set easily).

Does this hack cover all child objects under has_a/has_many for the 
parent object? 
http://search.cpan.org/~tmtm/Class-DBI-0.96/lib/Class/DBI.pm#TRANSACTIONS

-=Chris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3178 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.digitalcraftsmen.net/mailman/private/classdbi/attachments/20050808/2ed5bd83/smime.bin


More information about the ClassDBI mailing list