Yii2 - 值未通过 $model->save() 更新

Yii2 - Value Not Getiing Updated Through $model->save()

我正在使用 save() 更新用户详细信息。而且,我遵循了 yii 框架的指南,即 Yii2-Guide-Save()

$customer = Customer::findOne(123);
$customer->email = 'james@newexample.com';
$customer->save();

但是,它没有更新任何值。我不明白是什么问题。

什么时候,我在做var_dump($users->save());它正在显示bool(false). $confirmLinkID; 值来了。

这是我的控制器

public function actionResend()
{
    $model=new Users(); // User Model

    if ($model->load(Yii::$app->request->post())) {

        $post = Yii::$app->request->post('Users');

        $userDetails = $model->findOne(['email' => $post['email']]);

        // If Account Is Already Activated
        if($userDetails['status'] == 1) {
            Yii::$app->session->setFlash('AccountAlreadyVerified');
            return $this->refresh();
        }

        // If status == 2 
        if($userDetails) { 
            $confirmLinkID=$model->getAuthKey();
            $users = Users::findOne(['email' => $post['email']]);
            $users->auth_key = $confirmLinkID;
            $users->save();
        }
    }
}

请帮忙。

试试

 $customer->save(false);

如果使用参数 false 保存数据,那么您在验证规则方面遇到了一些问题(有选择地评论以找到引发问题的规则)

否则请检查您是否在模型中定义了可以shadow/override data/column 字段

的变量