2

Yii2. when I save ActiveRecord object that has autogenerated field date:

$obj = new Something();
$obj->name = 'abc';
// $obj->date.... not specified but generates by db engine
$obj->save();

Is it possible to get $obj->date without reinitializing object like

$obj = Something::findOne($obj->id);

?

1 Answer 1

4

Use ActiveRecord::refresh() which

Repopulates this active record with the latest data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.