RE: [PHP] event feeder
| From: | Richard Lynch | Date: | Sat, 27 Sep 2008 16:35:49 +0000 |
| Subject: | RE: [PHP] event feeder | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-281039@lists.php.net to get a copy of this message | ||
________________________________________
i would like to display on my web application, the latest 3 events added to
my web DB.
something like latest 3 event which happen to company.
what is the best way knowing that each event is translated in several
languages and stored into DB ?
should i directly read latest 3 events from DB using PHP ?
should i firstly query DB for each language, store the result into a txt
file (for example) and after using AJAX or PHP read this file ?
what do you use usally ?
If you can figure out the SQL to do it, that is almost always faster.
Even if you have to do 2 queries, hopefully simpler ones, it's still faster.
Relative Expense Operations:
EXPENSIVE
| Opening DB Connection (possibly not on localhost, possibly over socket versus TCP/IP stack moves
it down a level)
| Opening local file
| PHP loop through many many values
| Complicated DB "JOIN" with many many rows
| PHP loop through small number of values
| One more small simple DB query
CHEAP
Of course, you can make a mess of this with extremes like a very very very remote DB, or a 486 DB
server with an 8-cpu 64G RAM webserver or something "forced" to prove me wrong.
And, of course, "many" could mean different things on different hardware; You have to be
comparing on the same hardware, or it all goes out the window.
But the above is a general rule of thumb.
Hope that helps.
It sure would have been useful to me in the first few years of my PHP programming :-)
_______________________________________________________
The information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial use of the individual or entity to which it is
addressed and may contain information that is propri-
etary and confidential. If you are not the intended
recipient of this message you are hereby notified that
any review, dissemination, distribution or copying of
this message is strictly prohibited. This communica-
tion is for information purposes only and should not
be regarded as an offer to sell or as a solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be secure or error-
free. P6070214