验证后将数据放入数据库的更好方法是什么?我给你2个例子:
第一的
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Impossible to go on', 'required|xss_clean');
if ($this->form_validation->run() != FALSE) { // check the field validation
$username = $this->input->post('username'); // fist way
$this->model_db->insert_username($username);
}
第二
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Impossible to go on', 'required|xss_clean');
if ($this->form_validation->run() != FALSE) { // check the field validation
$username = $this->form_validation->set_value('login'); // second way
$this->model_db->insert_username($username);
}