config数据存储在数据库中 [英] config data stored in database

查看:122
本文介绍了config数据存储在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可能是完全错误的树,所以请原谅我,如果这不是我应该做的事情。

I might be barking up completely the wrong tree so forgive me if this isn't at all how I should be doing things.

我有一个配置表在我的数据库,这是为我的网站保存配置详细信息。我想将这些数据加载到config.php文件中的代码igniter?

I've a config table in my database which is to hold config details for my website. I want to load this data into the config.php file for code igniter?

这是我应该做还是完全错误?

Is this something I should be doing or totally wrong?

如果我在顶部config.php文件每次有人加载网站或只是第一次时,这将被调用?

If I put a database call at the top of the config.php file will this get called every time someone loads the site or just the first time?

对不起,如果这听起来完全愚蠢我有点困惑。

Sorry if this sounds totally stupid I'm a bit confused.

编辑

我不是指数据库详细信息,例如想存储类似邮件数量每页显示。我创建的脚本要在多个服务器上使用,每页的帖子数量,例如需要可编辑。我可以导致加载到一个会话,但我认为加载它作为一个常量*?在配置文件将是一个更好的主意。

I'm not meaning database details, for example want to store something like the amount of post to be shown per page. The script I'm creating is to be used on more than one server the amount of post per page for example needs to be editable. I could of cause load this into a session but I thought loading it as a constant*? in a config file would be a better idea.

推荐答案

您可以创建一个新模型,从数据库中提取配置选项,然后自动加载此模型,使其可全局使用。然后,您可以通过 $ this-> model_name-> function_name($ db_column); 访问您的选项,并具有 $ db_column 是您正在查找的选项的列名称,并让您的模型函数选择并返回列数据。

You could create a new model that pulls the config options from the database and then autoload this model so that it's available globally. Then, you could access your options via $this->model_name->function_name($db_column); and have $db_column be the name of the column for the option you're looking for and have your model function select and return the column data.

我个人使用自定义配置文件:

http://codeigniter.com/user_guide/libraries/config.html

Personally, I use a custom config file:
http://codeigniter.com/user_guide/libraries/config.html

这篇关于config数据存储在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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