动态更新配置数据代码 [英] Dynamically updating config data codeigniter

查看:97
本文介绍了动态更新配置数据代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了自定义配置文件来存储有关网站的信息,例如是在线还是离线样。

I have created my custom config file to store information about site such as if it is online or offline like-vice.

为此,我已经创建了一个新文件config文件夹,并在全局$ config []数组中使用自己的索引存储默认值。

For that I have created new file in config folder and stores default values in global $config[] array with my own index.

我想用管理员控制动态更新这些配置数据例如。他可以选择将网站置于离线模式。

I want to update these config data dynamically with admins control eg. he can select to put site in offline mode.

为此,我使用了函数

$this->config->set_item('config_array_index','value_to_set');

但我不知道为什么它不适合我?

but, I don't know why it is not working for me ?

我无法在我的配置文件中看到任何更新。还有我自动加载我的配置文件。
我缺少一些东西?

I am not able to see any update in my config file. Also I am autoloading my config file. Am I missing something?

推荐答案

设置配置项只适用于当前会话 - 实际上是代码信号文件。

Setting a config item only applies to the current session - it does not overwrite your actually codeigniter files.

如果你想永久性地使一个网站离线,你需要某种持久化存储,例如数据库中的值,根据需要更新

If you want to permanetly take a site offline, your'll need some sort of persistant storage, such as a value in a database that is checked/updated as needed

这篇关于动态更新配置数据代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆