Re: Copy row into another table
[prev]
[thread]
[next]
[Date index for 2004/09/23]
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
|
|
Re: Copy row into another table
Tony Bowden 17:32 on 23 Sep 2004
|