douwei1921 2015-01-06 11:52
浏览 11
已采纳

Codeigniter - 未保留配置项中的更改

I have a scenario in which I want to save an object in the config array. I save via

$this->config->set_item('obj', $obj);

It works, I can retrieve its value via:

$this->config->item('obj');

But this values is not being preserved properly. When I go from one page to another, the value is lost. I can store the value in session, cookie or database, but I don't want to. Is there a way I can store the value in some global variable, change it often and the value is preserved as long as the application is open?

  • 写回答

1条回答 默认 最新

  • dtbl1231 2015-01-06 12:23
    关注

    No, You can't.

    You are storing the config item at runtime. The config item is available as long as the script is running. So when a page is finished loading , it means the script has finished its execution and all the runtime data are also gone.

    In order to store it permanently , you must store it in session/database/filesystem.

    You can use PHP's serialize() function.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线