yii model-> save not working for update value

S R*_*ana 1 php mysql yii

public function actionUpdateprofile(){
    $user = User::model()->findByPk($_POST['User']['user_id']);
    $profile = Profile::model()->findByPk($_POST['User']['user_id']);

    if(isset($_POST['User']) || isset($_POST['Profile'])){
        $user->attributes = $_POST['User'];
        $profile->attributes = $_POST['Profile'];
        $user->save();
        $profile->save();

    }
}
Run Code Online (Sandbox Code Playgroud)

我做了这个代码来更新配置文件和用户表中的值.但它不起作用.如果我发送$_POST['Profile']['email'] = 'abc@gmail.com'; 没有错误但数据库仍显示旧值.为什么?

我在那里做错了什么?

这是结果$profile->attributes.电子邮件仍然具有旧价值.

Array
(
    [user_id] => 35
    [lastname] => asd
    [firstname] => asrtyr
    [email] => xyz.gmail.com
    [phoneno] => 123456
    [prof_img] => 
    [phoneno2] => 0
    [agentKey] => 
    [fb_id] => 
)
Run Code Online (Sandbox Code Playgroud)

MH2*_*2K9 5

我建议你添加如下错误报告

if(!$user->save()){
    echo 'Error to save user model<br />';
    var_dump($user->getErrors());
}
if(!$profile->save()){
    echo 'Error to save profile model<br />';
    var_dump($profile->getErrors());
}
Run Code Online (Sandbox Code Playgroud)