yii\db\BaseActiveRecord::refresh PHP Method

refresh() public method

If the refresh is successful, an [[EVENT_AFTER_REFRESH]] event will be triggered. This event is available since version 2.0.8.
public refresh ( ) : boolean
return boolean whether the row still exists in the database. If `true`, the latest data will be populated to this active record. Otherwise, this record will remain unchanged.
    public function refresh()
    {
        /* @var $record BaseActiveRecord */
        $record = static::findOne($this->getPrimaryKey(true));
        if ($record === null) {
            return false;
        }
        foreach ($this->attributes() as $name) {
            $this->_attributes[$name] = isset($record->_attributes[$name]) ? $record->_attributes[$name] : null;
        }
        $this->_oldAttributes = $record->_oldAttributes;
        $this->_related = [];
        $this->afterRefresh();
        return true;
    }