codingrhythm 发表于 2010-10-21 19:35:28

Kohana的Auth模块到底怎么用啊

代码如下,执行到check()的时候,总是ORM报错,是$this->pk()的地方,也就是主键不存在,但用户是新注册的,主键怎么可能存在值呢?这个问题怎么解决呢?

if ($_POST)
      {
            #Instantiate a new user
                        $user = ORM::factory('user');
                       
                    #Load the validation rules, filters and callbacks
                    $post = $user->validate_create($_POST);
   
            #Check that all fields are valid.
                    if ($post->check())
                    {
                            #Affects the sanitized vars to the user object
                            $user->values($post);
   
                            #create the account
                            $user->save();
   
                            #Add the login role to the user
                            $login_role = new Model_Role(array('name' =>'login'));
                            $user->add('roles',$login_role);
   
                            #redirect to the login page
                            Request::instance()->redirect('/');
                    }
                    else
                    {
                #Affects errors for further display
                            $this->template->content->errors = $post->errors('register');
                    }
      }
页: [1]
查看完整版本: Kohana的Auth模块到底怎么用啊