storage fix for fork() and workaround for Apache::DBI
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Schema.pm
index 59fca81..292aef8 100644 (file)
@@ -29,6 +29,7 @@ DBIx::Class::Schema - composable schemas
   __PACKAGE__->load_components(qw/PK::Auto::Pg Core/); # for example
   __PACKAGE__->table('foo');
 
+  # Elsewhere in your code:
   my $schema1 = My::Schema->connect(
     $dsn,
     $user,
@@ -247,6 +248,11 @@ sub compose_connection {
   }
 
   my $schema = $self->compose_namespace($target, $base);
+  {
+    no strict 'refs';
+    *{"${target}::schema"} = sub { $schema };
+  }
+
   $schema->connection(@info);
   foreach my $moniker ($schema->sources) {
     my $source = $schema->source($moniker);
@@ -275,8 +281,6 @@ sub compose_namespace {
   }
   {
     no strict 'refs';
-    *{"${target}::schema"} =
-      sub { $schema };
     foreach my $meth (qw/class source resultset/) {
       *{"${target}::${meth}"} =
         sub { shift->schema->$meth(@_) };
@@ -327,7 +331,31 @@ Conveneience method, equivalent to $schema->clone->connection(@info)
 
 =cut
 
-sub connect { shift->clone->connection(@_) };
+sub connect { shift->clone->connection(@_) }
+
+=head2 txn_begin
+
+Begins a transaction (does nothing if AutoCommit is off).
+
+=cut
+
+sub txn_begin { shift->storage->txn_begin }
+
+=head2 txn_commit
+
+Commits the current transaction.
+
+=cut
+
+sub txn_commit { shift->storage->txn_commit }
+
+=head2 txn_rollback
+
+Rolls back the current transaction.
+
+=cut
+
+sub txn_rollback { shift->storage->txn_rollback }
 
 =head2 clone