-1
public function respondent_info()
{
$data['states'] = $this->survey_model->get_states();
$state = $this->session->store['loginData']['state'];
$financial_year = $this->session->store['loginData']['financial_year'];
$getData = $this->survey_model->get_page($state, $financial_year);
if ($getData == '1') {
$data['res_info'] = $this->survey_model->get_resinfo_details($state);
$this->load->view('edit_respondent_info', $data);
}else {
$this->load->view('respondent_info', $data);
}
if(isset($_POST['submit_x'])) {
$respondentArray = array(
'state' => empty($_POST['state']) ? '' : $_POST['state'],
'name' => empty($_POST['name']) ? '' : $_POST['name'],
'title1' => empty($_POST['title1']) ? '' : $_POST['title1'],
'dline' => empty($_POST['dline']) ? '' : $_POST['dline'],
'email' => empty($_POST['email']) ? '' : $_POST['email'],
'organization' =>empty($_POST['organization']) ? '' : $_POST['organization'],
'address' => empty($_POST['address']) ? '' : $_POST['address'],
'city' => empty($_POST['city']) ? '' : $_POST['city'],
'state1' =>empty($_POST['state1']) ? '' : $_POST['state1'],
'zip' => empty($_POST['zip']) ? '' : $_POST['zip'],
'phone' => empty($_POST['phone']) ? '' : $_POST['phone'],
'fax' =>empty($_POST['fax']) ? '' : $_POST['fax'],
);
$this->session->set_userdata('respondent_info',$respondentArray);
$this->survey_model->auto_save_respondent_info($_POST);
redirect('survey/budget_overview');
}
}
模式
function auto_save_respondent_info($post){
echo("auto");
$respondentArray = array(
'survey_id' => $this->session->store['survey_id'],
'state' => empty($_POST['state']) ? '' : $_POST['state'],
'name' => empty($_POST['name']) ? '' : $_POST['name'],
'title1' => empty($_POST['title1']) ? '' : $_POST['title1'],
'dline' => empty($_POST['dline']) ? '' : $_POST['dline'],
'email' => empty($_POST['email']) ? '' : $_POST['email'],
'organization' =>empty($_POST['organization']) ? '' : $_POST['organization'],
'address' => empty($_POST['address']) ? '' : $_POST['address'],
'city' => empty($_POST['city']) ? '' : $_POST['city'],
'state1' =>empty($_POST['state1']) ? '' : $_POST['state1'],
'zip' => empty($_POST['zip']) ? '' : $_POST['zip'],
'phone' => empty($_POST['phone']) ? '' : $_POST['phone'],
'fax' =>empty($_POST['fax']) ? '' : $_POST['fax'],
);
$this->db->select('*');
$this->db->from('survey_respondent_info');
$this->db->where('state', $state);
$query = $this->db->get();
if ($query->num_rows() > 0)
{
echo("update");
// $this->db->where('state', $state);
// $this->db->update('survey_respondent_info', $resInfoArray);
}
else{
echo("insert");
// $this->db->insert('survey_respondent_info', $resInfoArray);
}
}
這裏沒有調用模型函數,我不能查看echo中給出的數據。如何調用它或如何將會話中存儲的數據發送到模型,我知道我的代碼中缺少某些東西,請有人可以幫助我。謝謝。
對不起,它不是打印任何 – user3165411
我需要的值存儲在會話中,也發送這些模型,以便存儲在分貝 – user3165411
您可以訪問您從模型發佈數據$ this-> input-> post ( '字段名');可以將數據保存到會話相同你沒有 –