Page 1 of 1

Variable storage question.

Posted: Thu Sep 23, 2010 11:39 am
by Gungneer
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

Re: Variable storage question.

Posted: Thu Sep 23, 2010 12:17 pm
by Jonah Bron
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

Re: Variable storage question.

Posted: Thu Sep 23, 2010 12:23 pm
by Gungneer
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
Umm.. That's what I already do...
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.

Re: Variable storage question.

Posted: Thu Sep 23, 2010 5:25 pm
by Jonah Bron
Gungneer wrote:Umm.. That's what I already do...
I know. I'm just saying that's fine.
Gungneer wrote:No, they don't contain any HTML.
Good.
Gungneer wrote:What I'm asking here is if doing this would be better than storing them all in the data base
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?