On Tue, Jun 01, 2010 at 10:24:59AM +0200, Gerhard Heift wrote:
> Hello
> 
> I have a $row object and want to get a clone of it, which is bound to a new
> database connection:

I found a solution for me:

sub clone_db {
        my $self = shift;

        my $schema = $self->result_source->schema->clone;
        my @connect_info = @{$schema->storage->connect_info};

        $schema = ref $schema;
        $schema = $schema->connect(@connect_info);

        my $clone = 
$schema->resultset($self->result_source->source_name)->new({$self->get_columns});

        $clone->{'_dirty_columns'} = {
                %{$self->{'_dirty_columns'}}
        } if exists $self->{'_dirty_columns'};

        $clone->{'_orig_ident'} = {
                %{$self->{'_orgi_ident'}}
        } if exists $self->{'_orig_ident'};

        $clone->in_storage($self->in_storage);

        return $clone;
}

Anything I missed in this solution?

Regards,
  Gerhard

Attachment: signature.asc
Description: Digital signature

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to