Ok, I have the plans for a set of scripts all set in my head, except one detail...
I plan on using a possibly large amount of varibles for controling everything from layout to page titles, etc..
Main question I've been wondering is, would it be better to stick all those variables into the database (MySQL, or SQLite most likely) and write a class to call them?
Or would I be best just sticking them in variable files and including them into every page?
From what I can tell, the latter option might rape my server in terms of memory usage, but I don't know for sure.
Main reason I'm asking here is because I've been busy at work recently so I've not had the time to do any tests.
So if anyone knows about the pros and cons for each method I would be greatful for any help with this, and if anyone has even done any benchmark testing or some pish and is willing to share the results, that would be fantastic.
Thanks in advance,
Alan
Variable storage question.
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Variable storage question.
You could put them into a file and include it. Are these variable containing HTML? Actually, you should put all values into an associative array. It makes things so much neater.
Another option is to use parse_ini_file().
http://php.net/parse-ini-file
Another option is to use parse_ini_file().
http://php.net/parse-ini-file
Re: Variable storage question.
Umm.. That's what I already do...Jonah Bron wrote:You could put them into a file and include it. Are these variable containing HTML? Actually, you should put all values into an associative array. It makes things so much neater.
Another option is to use parse_ini_file().
http://php.net/parse-ini-file
No, they don't contain any HTML.
And I ALWAYS use associative arrays.
What I'm asking here is if doing this would be better than storing them all in the data base and calling them when I need the specific vars because as it stands, I feel I have a lot of vars in my files already, and should I go with the method that's in my head for making a site, I would be looking at possibly storing a fair bit of data in vars mostly related to page information and layout.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Variable storage question.
I know. I'm just saying that's fine.Gungneer wrote:Umm.. That's what I already do...
Good.Gungneer wrote:No, they don't contain any HTML.
I read what you've said about the data so far, but what exactly are they holding? Can you give an example? And how many variables have you defined?Gungneer wrote:What I'm asking here is if doing this would be better than storing them all in the data base