Re: [PHP] Which is faster, a MySQL access, or a set of PHP variables?

2006-01-02 Thread Dave M G

Thank you for the advice.
The point was raised, and it's a good one, that if I'm getting content
from the database for most pages, then attaining the necessary
translations probably won't make a difference.
And of course, it is true that at my current levels of hits, the server
load is negligible. But, of course, one always hopes that site
popularity will increase and justify the efforts of making it efficient.
I think I am going to database the translations for now, and then later
if need be, I will go with the suggestions of creating a list of
variables from the database once a day with a cron job.

I appreciate all the help people have given to let me understand the
issue.

--
Dave M G

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Which is faster, a MySQL access, or a set of PHP variables?

2005-12-30 Thread Dave M G
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.

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.

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.

Opinions would be much appreciated.

--
Dave M G

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Which is faster, a MySQL access, or a set of PHP variables?

2005-12-30 Thread Jochem Maas

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



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Which is faster, a MySQL access, or a set of PHP variables?

2005-12-30 Thread Miles Thompson

At 10:32 AM 12/30/2005, 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.

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.

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.

Opinions would be much appreciated.

--
Dave M G


Dave,

I did that for an online auction site, now defunct, where the languages 
could be German or English. To expand to Spanish one had only to supply the 
structure and have someone who knew one of the other languages to enter the 
correct terms. That would be pasted into the script and run, presto, the 
site was available in Spanish.


Database hits ere not a problem, as all of the content on the page came 
from a database, none of the content was static.


That was three years ago, and it was done that way because native language 
support was wobbly in both PHP and Apache.


Joachem's solution is probably better for today.

Cheers - Miles Thompson 



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.371 / Virus Database: 267.14.9/216 - Release Date: 12/29/2005

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Which is faster, a MySQL access, or a set of PHP variables?

2005-12-30 Thread Richard Lynch
On Fri, December 30, 2005 8:32 am, Dave M G wrote:
   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?

If you are already connecting to the database, then you are comparing
an extra query or two to loading a file from the hard drive and the
database wins on performance.

Unless you are already loading some file where it would be convenient
to stick the text, and then the variables win.

Actually, this all depends on your hardware and database/drive
performance setup...

There really is NOT a good answer to this question from a
performance stand-point.

But then it's not a good question, really, unless you REALLY expect
your site to get a ton of traffic, because the performance of the
machine will probably not be a big factor in your success, compared to
maintainability of code, feature-set of the site, cool-ness and
prettiness and marketing and...  All of those will matter more to your
success than raw performance.

   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.

Something to consider:

Can you get data in other character sets into and out of your database
and web application?

If you plan to support 2-byte (or more) character sets, this is not
trivial at all -- or maybe it is, but you have to at least plan ahead
for it from the get-go.

   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.

   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.

Generally, on most projects, the people who are contributing the
translations of internal things like contact and previous page are
developers who are comfy with editing a text file, and putting them in
as text files with, say CVS or subversion, gives the developers
control over versioning etc.

That's not to say you COULDN'T do something similar with the database,
or run hourly dumps of (some) tables into CVS or something.

I don't think it's going to matter much which way you do this, so long
as you can plan ahead for all the character-encodings you will ever
need, and make sure you can handle them all.

Perhaps try it with a test phrase like Hello which you can probably
find in every language fairly easily.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php