This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Clone an object

Other symfony projects

Clone an object

by yonialhadeff » Wed Jul 30, 2008 10:51 pm

Hello,

I have two different object (table).

RequestInProcess AND Request. the object request as only a few fields more than RequestInProcess.

Is there an automatic way to copy RequestInProcess into Request ?

I tried this but it doesn't work

Code: Select all
$c = new Criteria();
$c->add(RequestInProcess Peer::ID,$requestInProcess _id);
      
$rs = RequestInProcess Peer::doSelectRS($c);

$request = RequestPeer::populateObjects($rs);
$request[0]->setDelivery(2);
$request[0]->setNew(1);
$request[0]->save();


if i do that, this is the query wich is executed

Code: Select all
INSERT INTO itemvol (DELIVERY,UPDATED_ON,CREATED_ON) VALUES (2,'2008-07-30 23:48:51','2008-07-30 23:48:51')


What can i do ?

Thanks

Yoni
yonialhadeff
Member
 
Posts: 38
Joined: Thu Feb 21, 2008 1:21 pm

Re: Clone an object

by cokker » Thu Jul 31, 2008 7:38 am

I don't see your problem. Can you clarify?

You want to copy the data from one object into an other of another type. right?

But what should be wrong with your SQL-statement?
Perhaps you can look at the function "copyInto(...)"

greets
Sven
cokker
Faithful Member
 
Posts: 591
Joined: Mon Jan 15, 2007 10:43 am
Location: Germany

Re: Clone an object

by yonialhadeff » Sun Aug 03, 2008 5:10 am

Hello,

I was needed the copyinto Method.

Thanks for your help,

Yoni
yonialhadeff
Member
 
Posts: 38
Joined: Thu Feb 21, 2008 1:21 pm

Re: Clone an object

by naholyr » Mon Oct 20, 2008 6:10 pm

We use this method to archive objects (kinda versionning)
Code: Select all
  EDIT : We didn't know BaseObject::copyInto()
  This part of the function has no reason to keep existing

I've cleaned up our code (in which we handle a copy of the primary key to a dedicated foreign key, and a few other things), but this is the idea based on TableMap you can use.
naholyr
Faithful Member
 
Posts: 223
Joined: Mon Jun 25, 2007 11:55 am