CakePHP 2.0 cannot save

邮差的信 提交于 2019-12-25 01:24:12

问题


I'm using CakePHP 2.0, I have the following save code:

$to_save = array(
            'User' => array(
                'uid'=>$uid,
                'firstname'=>$firstname,
                'lastname'=>$lastname,
                'bio'=>$bio,
                'gender'=>$gender,
                'link'=>$link,
                'username'=>$username,
                'email'=>$email
            )
        );

$this->User->create();

if( $this->User->save( $to_save ) ){
    echo 'User was saved.';
}else{
    echo 'User not saved.';
}

But it always output 'User not saved.' Thanks for any help!


回答1:


If there are no query errors, you probably have some validation rules in the model that prevent the data from saving. You can add debug( $this->User->invalidFields() ) to see if and which fields fail validation.



来源:https://stackoverflow.com/questions/9394080/cakephp-2-0-cannot-save

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!