我已檢查codeigniter的文件,但沒有特殊的頁面或關於它的信息。我想知道的是它是如何工作的。我有這個代碼,它的工作!,我想知道如何is_unique工作時,沒有任何模型或數據庫訪問。 is_unique是否有任何codeigniter中的類使用它來根據信息(如表名和字段)檢索數據? ,這就是代碼:如何codeigniter的is_unique []工作
echo form_input('email_address', set_value('email_address'), 'placeholder="Email"');
而且控制器:在視圖
電子郵件輸入
function create_member()
{
$this->load->library('form_validation');
// field name, error message, validation rules
$this->form_validation->set_rules('email_address', 'Email Address', 'trim|required|valid_email|is_unique[membership.email]');
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[4]');
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]|max_length[32]');
$this->form_validation->set_rules('password2', 'Password Confirmation', 'trim|required|matches[password]');
$this->form_validation->set_error_delimiters('<div class="alert alert-error"><a class="close" data-dismiss="alert">×</a><strong>', '</strong></div>');
if($this->form_validation->run() == FALSE)
{
$this->load->view('pages/signup_form');
}
else
{
$this->load->model('admin/Users_model');
if($query = $this->Users_model->create_member())
{
$this->load->view('pages/signup_successful');
}
else
{
$this->load->view('pages/signup_form');
}
}
}
和她的模型:
function create_member()
{
$new_member_insert_data = array(
'email' => $this->input->post('email_address'),
'user_name' => $this->input->post('username'),
'pass_word' => md5($this->input->post('password'))
);
$insert = $this->db->insert('membership', $new_member_insert_data);
return $insert;
}