0

在我看来,我有这段代码:

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');在我的视图和控制器中都使用,但没有成功。

4

1 回答 1

0

我只是放弃了,我在用户数据中设置了我的变量,如下所示:

$newdata = array(
    'tablename'  => 'faq_categories',
    'recordid'     => $faq_cat['catid'],
    'fieldname' => 'catid',
    'fieldToUpdate' => 'categoryphoto',
    'dpage' => 'faqcategories/editFaqCategory'
    );

干杯

于 2012-09-23T14:00:03.163 回答