[Bast-commits] r8464 -
DBIx-Class/0.08/branches/pod_fixes/lib/DBIx/Class/Manual
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Thu Jan 28 11:26:40 GMT 2010
Author: ribasushi
Date: 2010-01-28 11:26:40 +0000 (Thu, 28 Jan 2010)
New Revision: 8464
Modified:
DBIx-Class/0.08/branches/pod_fixes/lib/DBIx/Class/Manual/Cookbook.pod
Log:
RT#52681
Modified: DBIx-Class/0.08/branches/pod_fixes/lib/DBIx/Class/Manual/Cookbook.pod
===================================================================
--- DBIx-Class/0.08/branches/pod_fixes/lib/DBIx/Class/Manual/Cookbook.pod 2010-01-28 11:14:12 UTC (rev 8463)
+++ DBIx-Class/0.08/branches/pod_fixes/lib/DBIx/Class/Manual/Cookbook.pod 2010-01-28 11:26:40 UTC (rev 8464)
@@ -1821,13 +1821,28 @@
sub insert {
my ( $self, @args ) = @_;
$self->next::method(@args);
- $self->cds->new({})->fill_from_artist($self)->insert;
+ $self->create_related ('cds', \%initial_cd_data );
return $self;
}
-where C<fill_from_artist> is a method you specify in C<CD> which sets
-values in C<CD> based on the data in the C<Artist> object you pass in.
+If you want to wrap the two inserts in a transaction (for consistency,
+an excellent idea), you can use the awesome
+L<DBIx::Class::Storage::TxnScopeGuard>:
+ sub insert {
+ my ( $self, @args ) = @_;
+
+ my $guard = $self->result_source->schema->txn_scope_guard;
+
+ $self->next::method(@args);
+ $self->create_related ('cds', \%initial_cd_data );
+
+ $guard->commit;
+
+ return $self
+ }
+
+
=head2 Wrapping/overloading a column accessor
B<Problem:>
More information about the Bast-commits
mailing list