fuelPHP从db读取配置(fuelPHP read config from db)

编程入门 行业动态 更新时间:2024-10-28 20:23:25
fuelPHP从db读取配置(fuelPHP read config from db)

我在DB中有一个表,其中包含站点的全局设置。 我想在fuelPHP启动时加载这些参数并在所有控制器中使用它。 表列是id | setting_name | setting_value。 我使用了codeigniter,它被编码为帮助程序。 我调用了函数site_settings('parameter'),我得到了结果。 如何在燃料中做到这一点?

I have table in DB with global settings for site. I want to load these parameters when fuelPHP is starting and use it in all controllers. table columns is id|setting_name|setting_value. I used codeigniter and it was coded as helper. I called function site_settings('parameter') and i got result. How to do this in fuel?

最满意答案

您需要构建一个类才能使它与Fuel一起使用。

创建模型可能有意义,因为它是建立在数据库的钩子中。 查看Model_Crud或ORM。

http://fuelphp.com/docs/classes/model_crud/introduction.html http://fuelphp.com/docs/packages/orm/intro.html

如果需要,您可以访问这两个数据库并更新和创建设置。

然后,您将要将其添加到配置文件以使其自动加载。

http://fuelphp.com/docs/general/configuration.html

您还可以扩展核心Config类: http : //fuelphp.com/docs/classes/config.html http://fuelphp.com/docs/general/extending_core.html

这将使您可以访问包含基本getter和setter的cor配置方法。

You would need to build a class to get it to work with Fuel.

Creating a model might make sense since it's got built in hooks to a database. Check out Model_Crud or ORM.

http://fuelphp.com/docs/classes/model_crud/introduction.html http://fuelphp.com/docs/packages/orm/intro.html

Both of these will you can access your database and update and create settings if needed.

Then you will want to add it to the config file to have it autoloaded.

http://fuelphp.com/docs/general/configuration.html

You could also extend the core Config class: http://fuelphp.com/docs/classes/config.html http://fuelphp.com/docs/general/extending_core.html

which will give you access to the cor config methods which include the basic getters and setters.

更多推荐

本文发布于:2023-04-28 09:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1331394.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:db   fuelPHP   config   read

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!