当我使用CodeIgniter会话self.headerTitleLabel.superView.insertSubview(view: myNewView, belowSubview: self.headerTitleLabel)
并在数据库页面中插入数据时会无限循环。但无需使用set_flashdata
,即可正常运行。
set_flashdata
自动加载
$this->session->set_flashdata('success_msg', 'Successfully Inserted Settings');
redirect('admin/settings/sitesetting');
控制器
$autoload['libraries'] = array('database', 'form_validation', 'email', 'session', 'encrypt', 'user_agent','pagination','Pdf');
模型
public function sitesetting()
{
$data['title'] = 'Admin - Site Settings';
$data['setting'] = $this->AdminModel->selectalldata('tbl_settings');
$set = $data['setting'];
if(isset($_POST['submisetting'])){
$this->form_validation->set_rules('setting_text', 'Setting ', 'required');
if($this->form_validation->run() == FALSE){
$this->load->view('admin/setting',$data);
}else{
$value = $set[2]->id;
$data = array( "setting_value"=> $this->input->post('setting_text'));
$update = $this->AdminModel->updatedata('tbl_settings', 'id', $value, $data);
$this->session->set_flashdata('success_msg', 'Successfully Inserted Settings');
redirect('admin/settings/sitesetting');
}
}else{
$this->load->view('admin/setting',$data);
}
}
答案 0 :(得分:0)
$ this-> session-> set_flashdata(“ success_msg”,“成功插入设置”); redirect(''admin / setting',$ data');
然后在视图中
session-> flashdata('success_msg')):?> × session-> flashdata('success_msg'); ?>