Php Yii2-即使满足条件,数据也不会保存在db中,日志中也没有任何内容

Php Yii2-即使满足条件,数据也不会保存在db中,日志中也没有任何内容,php,yii2,Php,Yii2,这是我的代码,我遗漏了一些明显的东西,但无法找出: public function actionCheckout() { $model = new User; // $userProfile = UserProfile::find(['user_id'=>$model->id])->One(); $userProfile = new UserProfile; $cartItems = $this-&g

这是我的代码,我遗漏了一些明显的东西,但无法找出:

public function actionCheckout()
    {        
       $model = new User;
     //  $userProfile = UserProfile::find(['user_id'=>$model->id])->One();
       $userProfile = new UserProfile;
       $cartItems = $this->cart->getItems();

        if (Yii::$app->request->post())  {
            $cart = (array_merge(...$_SESSION['primary-cart']));         
            if($_POST['account-option']=="on"){
             //   echo "true";exit;
                $userProfile->first_name = $_POST['User']['first_name'];
                $userProfile->last_name = $_POST['User']['last_name'];
                $userProfile->phone = $_POST['User']['phone'];
                $userProfile->email = $_POST['User']['email'];
                $userProfile->address1 = $_POST['UserProfile']['address1'];
              //  $userProfile->address2 = $_POST['UserProfile']['address2'];
                $userProfile->city = $_POST['UserProfile']['city'];
                $userProfile->state = $_POST['UserProfile']['state'];
                $userProfile->Country = $_POST['User']['Country'];
                $userProfile->pincode = $_POST['UserProfile']['pincode'];
                $userProfile->save();
            }

            $params=[
                'id'=>$cart['productId'],               
                'amount'=> $cart['price'],
                'productinfo' => $cart['title'],                
                'firstname' => $_POST['User']['first_name'],
                'email' => $_POST['User']['email'],
                'phone' => $_POST['User']['phone']
            ];
            Yii::$app->Payu->PayuCheckout($params);

        }
        return $this->render('checkout',['model'=>$model,'userProfile' =>$userProfile,'cartItems' => $cartItems]);

    }
我被正确地重定向到payU,没有任何问题,但是数据没有保存到userProfile,日志中也没有任何内容。

试试看

var_dump($userProfile->getErrors()) 

保存后立即查看是否存在与模型字段相关的错误。

在$userProfile->savefalse中尝试使用false;谢谢有一个userid字段,这是必需的,您的建议可以帮助我找到它。