Jump to content

Recommended Posts

hello there,

i want to fetch settings from database and use them in most of the files in the project, e.g website_name i would like to get it from the database and put it in the <title> tag.

why i want to use the database instead of the php or ini file is so i can edit the settings from the web and not the file.

 

i already know how to fetch the data from the database and use it, but my question is what is the best practice to do so. should i fetch all the data at once and use foreach loop in the core file of the project or should i use a class or something, im really lost.

 

because most apps/forum use database settings such as mybb for example where u can edit the settings directly from the app but i dont know how to do it in a class, if someone could show me an example code i would really appreciate it.

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/315063-load-configsettings-from-database/
Share on other sites

The question is do you want your entire website to be completely broken if you have a database issue? I mean, not even able to render an error page?

Basic configurations are typically done in files because they're far more reliable, not to mention easier to modify and faster to read. Is there a particular reason you'd like to do a database instead?

  • Like 1
11 hours ago, requinix said:

The question is do you want your entire website to be completely broken if you have a database issue? I mean, not even able to render an error page?

Basic configurations are typically done in files because they're far more reliable, not to mention easier to modify and faster to read. Is there a particular reason you'd like to do a database instead?

so what are you saying that i should create an ini or json file and when i want to edit some settings i should just use open/write? there is no reason for the database, i just dont want messy code/more files, just looking for the best practical coding solution.

2 hours ago, RaiN3772 said:

so what are you saying that i should create an ini or json file and when i want to edit some settings i should just use open/write?

More or less. What sorts of settings are you thinking about? Files are more suited for things that you don't really ever need to change, like the name of the website or its domain name, not to mention "obvious" configuration stuff like database information and credentials.

 

2 hours ago, RaiN3772 said:

there is no reason for the database, i just dont want messy code/more files, just looking for the best practical coding solution.

What's "most practical" really depends on what you need to do, and how often...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.