[nycphp-talk] Saving variable value
Hans Zaunere
lists at zaunere.com
Mon Jan 9 23:22:38 EST 2006
Hi Amir,
Amir Aavani wrote on Monday, January 09, 2006 7:33 AM:
> Dear Friends,
>
> I want to know how PHP, apache act when the server receive a new request.
> For example, consider a user enter www.test.com/index.php, is it true
> that apache run the "php index.php" or something like this.
Long story short, yes. In a typical configuration, a file ending with .php
will be parsed and executed by PHP.
> I developed a web-site which needs to retrieve some data from database on
> every request. These data are dynamic and retrieving them from database
> take a long time.
>
> The point is that these data are altering every for example 2 hours. I
> have a solution to this problem but I want to know is there is any better
> solution.
There could be a huge number of solutions, depending on the application and
environment. To speed up database queries, consider tuning and indexing of
the database. Or, if the dataset/schema is very large and involves complex
processing, then you'll need to implement a caching or data massaging
scenario.
> I tried to write a IndexGenerator.php which is generate all possible
> output for index.php with different parameter. And on every request I
> send the content of the generated file on the disk to clients.
This would be in line with a caching implementation.
> The exact thing I want to know is that is there any way in php/apache, by
> which I can save the value of a variable and retrieve it on a different
> request.
There are, and they are called sessions, but it's likely not what you need
for this particular case. You could, however, use a session to store the
currently viewed file of data, and then change the session as needed to
display other types of data.
Best,
---
Hans Zaunere / President / New York PHP
www.nyphp.org / www.nyphp.com
More information about the talk
mailing list