mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-21 09:01:33 +08:00
Code optimization
This commit is contained in:
@@ -721,13 +721,14 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
|||||||
throw new StaleObjectException('The object being updated is outdated.');
|
throw new StaleObjectException('The object being updated is outdated.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($values[$lock])) {
|
||||||
|
$this->$lock = $values[$lock];
|
||||||
|
}
|
||||||
|
|
||||||
$changedAttributes = [];
|
$changedAttributes = [];
|
||||||
foreach ($values as $name => $value) {
|
foreach ($values as $name => $value) {
|
||||||
$changedAttributes[$name] = isset($this->_oldAttributes[$name]) ? $this->_oldAttributes[$name] : null;
|
$changedAttributes[$name] = isset($this->_oldAttributes[$name]) ? $this->_oldAttributes[$name] : null;
|
||||||
$this->_oldAttributes[$name] = $value;
|
$this->_oldAttributes[$name] = $value;
|
||||||
if ($name === $lock) {
|
|
||||||
$this->$lock = $value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->afterSave(false, $changedAttributes);
|
$this->afterSave(false, $changedAttributes);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user