我喜欢使用上次插入的id来接收特定行的值。 并将其存储在会话中。但我觉得有问题。有人会帮我吗?
控制器:
public function save_client() {
$data = array();
$data['client_first_name'] = $this->input->post('client_first_name', true);
$data['client_last_name'] = $this->input->post('client_last_name', true);
$data['client_email_address'] = $this->input->post('client_email_address', true);
$data['client_password'] = $this->input->post('client_password1', true);
$client_id= $this->w_list_model->save_client_info($data);
$sdata = array();
$sdata['client_id'] = $client_id;
//here is my problem
$sdata['client_first_name'] = $client_first_name;
$sdata['client_last_name'] = $client_last_name;
$sdata['login_status'] = true;
$this->session->set_userdata($sdata);
redirect('welcome/see_details');
}
我无法在会话数据中存储附加值(client_id除外)。
模型
public function save_client_info($data) {
$this->db->insert('tbl_client', $data);
$client_id = $this->db->insert_id();
return $client_id;
}
答案 0 :(得分:1)
您应该能够使用帖子数据,因为这些值与从数据库中检索它的值相同:
$sdata['client_first_name'] = $data['client_first_name'];
$sdata['client_last_name'] = $data['$client_last_name'];