The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Hardcoding in PHP versus SQL
Hi,
I have a list of about 10 categories that I need to display. Right now I have the categories in the database and I am using 1 SQL query to get them. I am thinking that I can hard-code the list of categories in PHP in order to avoid quering the database. The down side of this is that I need to update the list of categories in 2 places (in the database and in the PHP file) if I choose to add more categories in the future. The "bright side" of the "downside" is that the list of categories will be updated VERY rarely (possibly never). What do you think of this ? Should I hard-code in PHP ? Regards, Razvan M. |
#2
|
|||
|
|||
One query isn't much of a differance if there's only 10 results. I'd go with SQL but thats just me.
|
#3
|
|||
|
|||
You could consider storing the categories also as a serialised array in the datastore table. This would reduce the number of extra queries to 1 (which often can be combined with reading other datastore values).
|
#4
|
|||
|
|||
Quote:
Since I am not using datastore values anywhere else in my mod there is no advantage from this point of view: I mean, I am already using just 1 query to retrieve the results. One more question: how do I serialize values to the datastore ? Is there some VB class to do this ? Quote:
Maybe I should make the table storing this data of type MEMORY. Since it is very small there should be no problem here. Currently the storage engine is INNODB. |
#5
|
|||
|
|||
An in MEMORY (HEAP) table is cleared on each restart of the MySQL server and not suitable for permanent storage (hence why vB only uses HEAP for session tables).
You can find various articles that include information on how to use the datastore, one of them: Cache System Explanation (datastore) PS Using the datastore can reduce the number of queries as vBulletin already read all needed rows from the table. |
#6
|
|||
|
|||
Quote:
Quote:
Exactly what I was looking for. Thank you. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|