Codeigniter Database Configuration Settings

I am building an application using the latest copy of Codeigniter 2.0. My application is dynamic and looks like a custom CMS, I think you could say. I have a database table called "settings" with the following fields:

  • ID
  • name
  • value

Basically, what I'm doing now is using a helper function to retrieve specific parameters from my settings table, such as the site name or current topic. However, I began to think that there might be too many database queries to get the settings in the database.

Is there a way to get the settings for my application from the database and then add them to my configuration file? I noticed that Mojomotor is doing something similar, and this is a CI 2.0 application, however I would prefer the simplest and easiest code to do this.

I would like to be able to check each so often if the configuration in the database has changed and update the configuration file. The lower the voltage in the database, the better.

+3
source share
1 answer

The best solution lies in the middle. Non-null DB calls; and not one call to the database installation. Instead, use one DB call to load the page and get all the settings in the recordset / object that the rest of your application can reference as needed.

+5

Source: https://habr.com/ru/post/1789399/


All Articles