0
Kohana很新穎,我在php中開發了一段時間。目前我正在嘗試創建一些自定義驗證規則。使用OOTB驗證規則,代碼可以正常工作,但是當兩個自定義驗證規則收到錯誤消息時。Kohana自定義驗證規則錯誤ReflectionException
ReflectionException [ 0 ]: Class Account_Model does not exist
下面所有的代碼模型中發現所謂的帳戶
public static function unique_username($username)
{
//check to see if username existsin the database
return ! DB::select(array(DB::expr('COUNT(username)'), 'total'))
->from('users')
->where('username', '=', $username)
->execute()
->get('total');
}
public static function unique_email($email)
{
// Check if the email already exists in the database
return ! DB::select(array(DB::expr('COUNT(email)'), 'total'))
->from('users')
->where('email', '=', $email)
->execute()
->get('total');
}
public function validate_new_user($post){
$valid_post = Validation::factory($post);
$valid_post->
->rule('username', 'Account_Model::unique_username')
->rule('email', 'Account_Model::unique_email'));
if ($valid_post->check()) {
return array('error' => false);
} else {
return array('error' => true, 'errors' => $valid_post->errors('default'));
}
}
啊我很接近。感謝您抽出寶貴時間來看看。 – user3032973