Php Can';t在yii2中更新数据库

Php Can';t在yii2中更新数据库,php,yii,Php,Yii,Yii文档说updateAttributes绕过验证,记录直接更新到数据库中。 在我的型号中: use yii\base\Component; use frontend\models\Notifications; class Notify extends \yii\db\ActiveRecord { public function send($user, $text){ $model = new Notifications(); if ($mo

Yii文档说updateAttributes绕过验证,记录直接更新到数据库中。 在我的型号中:

use yii\base\Component;
use frontend\models\Notifications;

class Notify extends \yii\db\ActiveRecord
{


    public   function send($user, $text){
         $model = new Notifications();
        if ($model->updateAttributes(['created_on'=>'2015-11-12 12:12:15', 'user_id'=>$user, 'text'=>$text])) return true;
        else return $this->getErrors();
    }
    public function notify($users, $text){

        $arr[] = array();
        foreach ($users as $user){
            $result = $this->send($user, $text);
             $arr[]= $result;

        }
    return $arr;
    }
}
在我的控制器中

 $notify  = new Notify;
 $response = $notify->notify([1, $guardian], $note);
 var_dump($response);
现在的问题是数据库既没有更新,也没有显示任何错误

我尝试静态调用该方法,但数据库仍然没有更新。 我尝试调用$model->save()。。但数据库仍然没有更新

更新: 我发现,即使在使用updateAttributes时,实际上也会发生验证错误。现在的问题是,为什么会这样,而Yii文档说它无法验证

更新2:
我错误地使用了$this->getErrors(),我用$model替换了$this

如果您对
$model->save()有问题,使用:

$model->save(false)
这就解决了你的问题


如果使用
$model->save()过滤器正在运行,这对您不好。

您是否尝试过
$model->save(false)
?它将跳过其他字段验证。是,它可以工作。谢谢