是啊俊
- 是啊俊 2017-09-22 已签到连续签到6天,获得了20个金钱
- 是啊俊 2017-09-21 已签到连续签到5天,获得了20个金钱
- 是啊俊 回复了 johnny1991 的回答
yii\db\baseActiveRecord
public function afterSave($insert, $changedAttributes) { $this->trigger($insert ? self::EVENT_AFTER_INSERT : self::EVENT_AFTER_UPDATE, new AfterSaveEvent([ 'changedAttributes' => $changedAttributes ])); }
调用
protected function updateInternal($attributes = null) { if (!$this->beforeSave(false)) { return false; } $values = $this->getDirtyAttributes($attributes); if (empty($values)) { $this->afterSave(false, $values); return 0; } $condition = $this->getOldPrimaryKey(true); $lock = $this->optimisticLock(); if ($lock !== null) { $values[$lock] = $this->$lock + 1; $condition[$lock] = $this->$lock; } // We do not check the return value of updateAll() because it's possible // that the UPDATE statement doesn't change anything and thus returns 0. $rows = static::updateAll($values, $condition); if ($lock !== null && !$rows) { throw new StaleObjectException('The object being updated is outdated.'); } if (isset($values[$lock])) { $this->$lock = $values[$lock]; } $changedAttributes = []; foreach ($values as $name => $value) { $changedAttributes[$name] = isset($this->_oldAttributes[$name]) ? $this->_oldAttributes[$name] : null; $this->_oldAttributes[$name] = $value; } $this->afterSave(false, $changedAttributes); return $rows; }
谢谢,我问的是这些事件绑定的地方,不是触发的地方,也就是类似:$this->on(self::EVENT_AFTER_INSERT, ...),不知道在哪里写 的
- 是啊俊 2017-09-20 已签到连续签到4天,获得了20个金钱
- 是啊俊 2017-09-19 已签到连续签到3天,获得了15个金钱
- 是啊俊 2017-09-18 已签到连续签到2天,获得了10个金钱
- 是啊俊 2017-09-17 已签到连续签到1天,获得了5个金钱