Here is the code:
...
$model->id=0;
$model->save();
//DB trigger changes id to some value...
$model->refresh();
echo $model->id;
//still 0 !!!
...
What is wrong? And how to get $model->id correct value?
Thank you in advance.
Here is the code:
...
$model->id=0;
$model->save();
//DB trigger changes id to some value...
$model->refresh();
echo $model->id;
//still 0 !!!
...
What is wrong? And how to get $model->id correct value?
Thank you in advance.
Try to don’t set $model->id. I think it is being checked for NULL before assignment in save() method.
First off, don’t set model id if it is a new row. Secondly, don’t call refesh. Model id is set for you by AR.