Im using Doctrine and I need to clone an object.
Two tables in the database have the same columns, but one exists for backlog orders whilst one is confirmed orders. Probably not the best way to do it, but they must be seperate as certain foreign keys cannot be satisfied on backlog objects.
So, I need to clone one object from the backlog and insert it into the current orders table. But if I clone the backlog order object, it will set the class to backlog order.
$backlog_orders = $this->Subscription_model->getBacklogOrders();
foreach($backlog_orders as $backlog_order){
$new_order = new Entities\NewOrder;
$new_order = clone $backlog_order;
//Do other stuff to new order
//At this point, I need to change the class of the object to NewOrder so that it will insert it into the correct table
echo get_class($order); // Outputs BacklogOrder
$this->Subscription_model->updateOrder($order); // Saves to DB
}