在我的数据库中,我有多种类型的用户,具体取决于某人注册的帐户类型。我创建了一个验证规则,用于检查某人是否注册了数据库中的用户名或电子邮件,但是我需要能够检查数据库中的正确表。CodeIgniter将第二个参数传递给回调
function create_account($account_type){
$this->load->library('form_validation');
$this->form_validation->set_rules('f_name','First Name','trim|required');
$this->form_validation->set_rules('l_name','Last Name','trim|required');
$this->form_validation->set_rules('u_name','Username','trim|required|min_length[6]|max_length[30]|callback_check_if_username_exists');
$this->form_validation->set_rules('email','Email','trim|required|valid_email|callback_check_if_email_exists');
}
我的检查用户名回调需要两个参数,username和account_type。联机帮助只会介绍传递即时值或其他后期值。你如何将account_type传递给回调函数?
function check_if_username_exists($name,$account_type){
$this->load->model('membership_model');
$username_available = $this->membership_model->check_if_username_exists($name,$account_type);
if($username_available){
return true;
}
else {
return false;
}
}
的
验证从哪里'$ account_type'来自何方?? – Saty