【问题标题】:codeigniter flashdata never arrive in my controllercodeigniter flashdata 永远不会到达我的控制器
【发布时间】:2012-09-23 11:31:45
【问题描述】:

我认为有这段代码:

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-&gt;session-&gt;keep_flashdata('item');,但没有成功。

【问题讨论】:

    标签: codeigniter


    【解决方案1】:

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

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

    干杯

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-24
      • 1970-01-01
      相关资源
      最近更新 更多