我的观点中有这个代码:
if (($faq_cat['categoryphoto'] !="")|| ($faq_cat['categoryphoto'] != NULL)) {
$this->session->set_flashdata('tablename', 'faq_categories');
$this->session->keep_flashdata('tablename');
$this->session->set_flashdata('recordid', $faq_cat['catid']);
$this->session->set_flashdata('fieldname', 'catid');
$this->session->set_flashdata('fieldToUpdate', 'categoryphoto');
$this->session->set_flashdata('dpage', 'faq/editFaqCategory');
echo anchor('faqcategories/updateOneField', 'Delete Current Photo?');
}
在我的控制器中,我有以下代码:
public function updateOneField()
{
$tablename = $this->session->flashdata('tablename');
$id = $this->session->flashdata('recordid');
$fieldname = $this->session->flashdata('fieldname');
$fieldToUpdate = $this->session->flashdata('fieldToUpdate');
echo "<br />table name is: " .$tablename;
echo $id;
echo $fieldname;
echo $fieldToUpdate;
die();
$this->load->model('faqCategoriesModel');
$this->faqCategoriesModel->save(array($fieldToUpdate => ''), $id);
$catid = $id;
$this->displayEditFaqCategoryForm($catid);
} // end of function updateOneField
任何尝试读取通过闪存数据发送的数据都会失败。所有flashdata变量都是空的。我在autoload.php文件中加载会话。这个相同的代码适用于另一个CI应用程序。谁能发现我做错了什么?我试图在我的视图和控制器中使用$this->session->keep_flashdata('item');
,但没有任何成功。
答案 0 :(得分:0)
我放弃了,我在userdata中设置变量,如下所示:
$newdata = array(
'tablename' => 'faq_categories',
'recordid' => $faq_cat['catid'],
'fieldname' => 'catid',
'fieldToUpdate' => 'categoryphoto',
'dpage' => 'faqcategories/editFaqCategory'
);
干杯