Cloning a DB record

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



// what I need to do in order to make that working



// returns model


$recordB = clone $recordA;


$recordB->isNewRecord = true;



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


		$model = clone $copyModel;

		$model->attributes = $copyModel;

		$model->isNewRecord = true;



		$model->dateBill = 0;

		$model->invoiceId = '';

		if ($model->save()) {

echo $model->id;


echo $model->id; is empty

my mistake:


this works