Hi,
Perhaps a noob question, but I didn’t find any answers around.
When I save model inside transaction, how do I retrieve (if possible at all) new record id before committing?
My code:
$transaction = Yii::app()->db->beginTransaction();
...
try {
$model->save();
$new_id = $model->id;
...
$something->something = $new_id;
$something->save();
$transaction->commit();
}catch(Exception $e){
$transaction->rollback();
}
Unfortunately, this does not work - $model->id is empty.
Please enlighten me - what am I missing.
Thanks in advance!