English 中文(简体)
kohana登记回归错误
原标题:kohana registration returns error

我有工作登记稿,唯一的问题是,我不知道如何核实用户名称是否已经存在,因为现在如果电子邮件或用户名称已经存在,那就给我造成这一致命错误:ORM_Validation_Exception [0]: 未能验证阵列[1174]

我在此说:

$validate = Validation::factory($values)
        ->rule( name ,  not_empty )
        ->rule( password ,  matches , array( :validation ,  password ,  repeat-password ))
        ->rule( password ,  not_empty )
        ->rule( email ,  email )->rule( email ,  not_empty )
if(!$validate->check()){
    $errors = $validate->errors( registration , true);
    foreach($errors as $value){
        echo $value . "<br />";
    }
    return;
}
$model = ORM::factory( user );
$model->values(array(
     username           => $values[ name ],
     email              => $values[ email ],
     password           => $values[ password ],
     password_confirm   => $values[ repeat-password ],
));

采用3.2版本。

最佳回答

To find out if an entry exists...

$model = ORM::factory( user , $values[ name ]);

if ( !$model->is_loaded() ) {
    // do registration
}

这将试图寻找一个用户模型(如果该模型被设定为主关键)。

问题回答

暂无回答




相关问题
Kohana ORM relationships question

I have tables: users {id, name} projects {id, name} roles {id, name} projects_users {id, user_id, project_id, role_id} I have models: project { has many users through projects_users } user { has ...

How to delete all user roles in Kohana 3

I m using ORM Auth module and it s difficult to figure out how to do it. I ve tried this case: $user = ORM::factory( user , $id); $user->roles->delete_all(); And got error ErrorException [ Fatal ...

Kohanav3 ORM: calling where->find_all twice

When I do something like the following: $site = ORM::factory( site )->where( name , = , Test Site )->find(); $users = $site->users; $deletedusers = $users->where( deleted , = , 1 )-&...

Kohana 3 simple relations

I m trying to write a very simple cms (for learning purposes) in kohana 3 web framework. I have my db schemas and i want to map it to ORM but i have problems with relations. Schemas:articles and ...

Kohana PHP - Multiple apps with shared model

I m using Kohana 3 to create a website that has two applications, an admin application and the actual site frontend. I have separated my folders to have the two applications separated, so the ...

Favourite Kohana Tips & Features? [closed]

Inspired from the other community wikis, I m interested in hearing about the lesser known Kohana tips, tricks and features. Please, include only one tip per answer. Add Kohana versions if necessary. ...