johnny1991

johnny1991

xxxxxxxxxxxxxxxxxxxxx

  • 财富值3285
  • 威望值580
  • 总积分9895

个人信息

  • 2017-09-24 已签到
    连续签到1天,获得了5个金钱
  • 回复了 的回答

    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;
        }
    

    系统没有监听这个事件,系统提供这个触发这个事件,是给开发者监听的

  • 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;
        }
    
  • 如此简单的描述,怎么解答?至少你要把你这个类截图给大家看看

  • 如此简单的描述,怎么解答?至少你要把你这个类截图给大家看看

  • 回复了 的回答

    首先,你要确保postcontroller里面是不是用了AccessControl
    其次,accesscontrol的roles为‘?’表示不需要登陆就可以访问,'@'表示登陆用户才可以访问,所以你要看看你的'approve'是不是写入到了指定的规则里面,如果用了accesscontrol就必须要指定approve的访问roles,不然访问不了的

副总裁 等级规则
9895/10000
资料完整度
60/100
用户活跃度
0/100

Ta的关注

19

Ta的粉丝

26

Ta的访客

81