emix
(Michal)
1
Hi… how can I clone a record in database? I need to delete it and then save again as he was
that of course does not work
// returns model
$record=$this->loadObject($id);
$record->delete();
// what I need to do in order to make that working
$record->save();
jonah
(Poppitypop)
2
<?php
// returns model
$recordA=$this->loadObject($id);
$recordB = clone $recordA;
$recordA->delete();
$recordB->isNewRecord = true;
$recordB->save();
mb1
(mb)
3
hi,
how can i get the new record id like mysql_insert_id() when i clone a record?
i need it because i will clone some relations of this
$copyModel=$this->loadInvoice();
$model = clone $copyModel;
$model->attributes = $copyModel;
$model->isNewRecord = true;
$model->id='';
$model->status=Invoice::STATUS_DRAFT;
$model->dateBill = 0;
$model->invoiceId = '';
if ($model->save()) {
echo $model->id;
}
echo $model->id; is empty
my mistake:
$model->id='';
this works
unset($model->id);