model->save() Not Working In Yii2

后端 未结 10 1559
情歌与酒
情歌与酒 2020-12-06 01:10

Previously, I was not using $model->save() function for inserting or updating any data. I was simply using createCommand() to execute query and

10条回答
  •  情话喂你
    2020-12-06 01:55

    You are doing all staff correct. I think u must add one line for confirm password validation

    if(!$CheckExistingUser) {    
    $auth_key = $model->getConfirmationLink();
            $password = md5($post['password']);
            $registration_ip = Yii::$app->getRequest()->getUserIP();
            $created_at = date('Y-m-d h:i:s');
    
            $model->auth_key = $auth_key;
            $model->password = $password;
            $model->confirm_password= md5($post["confirm_password"]);  /// add  this line
            $model->registration_ip = $registration_ip;
            $model->created_at = $created_at;
    

    And Also after this condition check model attributes and error like this :

    if($model->save()) {
              print_r("asd");
            }else{
    var_dump($model);exit;}
    

提交回复
热议问题