Hi,
I have a problem. I am writing a web site that has one index file, then based on the "module name" I pass it, it will call a function that will match up the module name and return an array consisting of the page title, description, and filename for the content to be included. My problem is that my "coder conscience" is telling me that I should not store this data in an array, because it's hard coded into the script, and that I should store it in a MySQL table. However, this of course will inevitably use more resources if the database has to be queried every single time a user visits a page to determine this data.
Is either way horribly bad design?
Thanks.
To store in an array or SQL database, that is the question.
Moderator: General Moderators
Re: To store in an array or SQL database, that is the question.
It depends on how often pages are added or removed, and how often the page metadata changes. Either way can be fine. I manage an ecommerce site, and the customer facing side is all database driven because content and products are added and changed often. On the flipside, the administrative interface is quite static in layout, so all of the page titles and links are arrayed.
You could create a config.inc.php file and add all configuration to that. Then just include the file anywhere it's needed. That way, you can edit the data later without actually opening your webpage code, and could also include the file on other pages that may need it.
You could create a config.inc.php file and add all configuration to that. Then just include the file anywhere it's needed. That way, you can edit the data later without actually opening your webpage code, and could also include the file on other pages that may need it.