mysql 与 ini 文件?

发布于 2024-09-07 11:34:13 字数 116 浏览 3 评论 0原文

我的 php 程序分为多个模块,每个模块都有自己的设置。这些设置几乎不会改变,那么将设​​置放在ini文件中还是放在mysql数据库中会更好呢?

如果我采用 ini 风格,那么更新 ini 文件有多难?

My php program is broken up into modules and each module has its own settings. These settings will hardly change, so would it be better to put the settings in a ini file or in a mysql database?

If I go with the ini style then how hard is it to update the ini file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夜空下最亮的亮点 2024-09-14 11:34:13

用于配置的简单文本文件有几个优点。最重要的是,您可以使用版本控制系统来比较修订版本并列出配置文件的历史记录。
另一个优点是,您不需要特殊的工具来编写/更改配置设置。只需启动一个文本编辑器(VI 即;-))

A simple text file for configuration has several advantages. Most of all you can use a version control system to compare revisions and to list the history of your configuration files.
Another advantage is, that you dont need a special tool to write/change configuration settings. Just fire up a text editor (VI that is ;-) )

飘过的浮云 2024-09-14 11:34:13

静态站点范围的配置设置可能最好存储在配置文件(INI 或 XML)中。用户特定的配置设置(即用户指定的主题、语言选择)可能更好地存储在数据库中(尽管您也可以将它们存储在唯一命名的配置文件中)。

至于更新 ini 文件有多困难:这取决于您存储在其中的设置数量。为了使这对您自己来说更容易一些,您可以为每个模块创建部分,这样您就可以跳转到相关部分并快速更改配置变量。

IE。

[module1]
var1=value1
var2=value2
...
[module2]
varX=valueX
varY=valueY
...

Static site-wide configuration settings are probably best stored in configuration files (INI or XML). User specific configuration settings (ie. user specified theme, language selection) are probably better stored in a database (though you could just as well store these in uniquely named config files).

As for how hard it is to update the ini file : that will depend on the number of settings you store in it. To make this a bit easier on yourself you could create sections per module, so you can jump to the relevant section and quickly change the config vars.

ie.

[module1]
var1=value1
var2=value2
...
[module2]
varX=valueX
varY=valueY
...
つ低調成傷 2024-09-14 11:34:13

如果我采用ini样式,那么更新ini文件有多难?

就像打开编辑器一样困难(例如两次击键:vi)。您应该正确记录您的设置。无论如何,这种方法应该优于在数据库中存储配置设置(即使是很少使用的设置)。

If I go with the ini style then how hard is it to update the ini file?

As hard as opening an editor (e.g. two keystrokes: vi). You should document your settings properly. Anyway this approach should be preferred over storing configuration settings (even seldom used ones) in the database.

烧了回忆取暖 2024-09-14 11:34:13

您还可以去掉中间人并将配置存储在 PHP 数组中(无需解析 INI、XML 或其他任何内容,如果是这种情况)。真正取决于谁最终会维护该文件(开发人员或非开发人员)

You could also take out the middle man and have the config stored in a PHP array (no need to parse an INI, or XML, or whatever if that's the case). Really depends on who would end up maintaining the file (developer or non)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文