Re: Copy row into another table

[prev] [thread] [next] [Date index for 2004/09/23]

From: Tony Bowden
Subject: Re: Copy row into another table
Date: 17:32 on 23 Sep 2004
On Thu, Sep 23, 2004 at 11:54:32AM -0400, Lance A. Brown wrote:
> I have a situation where I need to do the equivalent of:
> insert into expired
>   select NULL, NULL, clients.*
>     from clients
>     where client_id = ?
> The two tables have the same columns except that expired has an 
> expired_id (primary key, auto_increment) and a expired_time 
> (TIMESTAMP) field, which is where the two NULL values in the select 
> come in.

For now you can probably use move() for this. It's deprecated and
disappearing, mostly because it doesn't actually move() anything. Ideally
this functionality will become part of copy() somehow.

If you don't want the warning, then move() is really only a one-liner
anyway:

  NewClass->create($old_object->_data_hash());

You can also pass extra args to _data_hash if you need to add other
values. 

So really you have the choice between using a deprecated method or a
private one :)

Of course you should neatly encapsulate whatever approach you take into
your application base class, so that you can adjust it easily later when
we have a better way.

Tony

Copy row into another table
Lance A. Brown 15:54 on 23 Sep 2004

Re: Copy row into another table
Tony Bowden 17:32 on 23 Sep 2004

Re: Copy row into another table
Lance A. Brown 17:48 on 23 Sep 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52