[Dbix-class] Clone DBIx::Class::Row object to new connection

Alexander Hartmaier alexander.hartmaier at t-systems.at
Wed Jun 2 08:00:30 GMT 2010


Can you tell us why you want this?

--
Best regards, Alex


Am Dienstag, den 01.06.2010, 16:28 +0200 schrieb Gerhard Heift:
> 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


*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*



More information about the DBIx-Class mailing list