You are here: Re: [PHP] Which is faster, a MySQL access, or a set of PHP variables? « PHP « IT news, forums, messages
Re: [PHP] Which is faster, a MySQL access, or a set of PHP variables?

Posted by Jochem Maas on 12/30/05 16:53

Dave M G wrote:
> PHP General,
>
> I have a site where I will set the interface up to be multilingual.
> This means that all the snippets of text which make up the menu and
> other elements of navigation common to most pages will be stored as
> variables.
>
> In most web site set ups that I have seen, especially on forums, the
> text is stored in a PHP script which is just a long list of variables.
>
> I wondered if there was any downside to storing the list of interface
> texts in a MySQL database, then calling them as an array when the page
> loads?
>
> This would have one minor advantage, which is that as I expand to new
> languages, I could build a simple web interface where people could input
> new languages into a form.

true - rather than trying to writing an interface thats _properly_ capable
tf editing phpb-like language files - which although not impossible is a lot
more difficult to make fool-proof than one first imagines (I have very
ingenious 'fools' who want to edit stuff like that!)

>
> However, is it a drag on a server to have to reach into the MySQL
> database to retrieve the array of texts each time the page loads? Note
> that the texts will be something like 20 to 30 small one to four word
> phrases like "contact" and "previous page" and that sort of thing.

using var_export() you can write the array to a file on a TMPFS filesystem
(e.g. /dev/shm) as a cache and have a cmdline script or something that you run
whenever you want the lang itmes to be updated - reading a single small file in off
disk (which in the case of TMPFS is in RAM - bonus!!!) will be faster in general
than querying MySQL and building the array.

essentially this gives you the best of both world - with the added bonus of
begin able to easily control publication of updates to the lang items.

>
> On the surface, it doesn't seem like this would be much different than
> accessing a PHP script with a list of variables. But then, I figured
> there might be a reason why I've never seen it done this way.

basically unless you have some killer site thats taking a beating and
needs to take performance very seriously in order to stay in the air then either
way will do fine. a DB call on every request is somewhat wasteful but a low traffic
site won't mind one little bit.

>
> Opinions would be much appreciated.
>
> --
> Dave M G
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация