简体   繁体   中英

Storing website parameters in a database or flat files

For the most part, the 3 sites for an organization I run have a single MySQL database that they share. This allows them to interact with each other nicely.

I have a bunch of simple parameters that the sites need to know about, and I wasn't sure what the best route to take is:

  1. Make a table with 2 fields (key, value) where I store the params
  2. Store the values in one or many flat files

They each have advantages and disadvantages.

The database allows a single entry to be used for all three sites (however, this doesn't occur often), all the information is centralized, and the interface is already well defined.

The flat files are easier to work with as FTP and a text editor can be used in addition to website administration, the flat files can be written as PHP meaning the site doesn't have to do any parsing (just need to include the file and use the variables), but they can't be shared between sites.

I can go on and on. What do you think is the better route to take?

My opinion is to use a database if you have the chance. It's easier on the long run. You have built the website, with the flat files, but now the customer wants an additional page with slightly other parameters, so you have to add a new file. Now you are done with this and he ask you again.. well, you get the point.

It is not organised at all. So if you have the chance to use a database, use it. There is reason why it is invented.

But just to get my thoughts clear and firmly know what you are talking about, please tell me more about the settings you would like to store. I can imagine that you are talking about some global variables, or maybe even going to use a define(), but it is also possible you want to store strings. So please define "bunch of simple parameters" for us.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM