By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,890 Members | 1,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,890 IT Pros & Developers. It's quick & easy.

Session ? Static ?

P: n/a
All,
I have a function that returns data from my db as an array. To reduce the
times the script
has to access the db should I store the contents of the variable in a
session variable and
access it that way, or should I figure out how to set it and use it as a
static variable ?

I was thinking doing an isset on the session var, if exists, use it, if not,
hit the db and store the
session var. Also, the data that is stored in the db will not change too
often, my sessions will
expire way before that so I dont have to worry about "stale" data.

Ideas ?
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

On Tue, 29 Jun 2004 21:49:26 -0800, "StinkFinger" <st****@pinky.com>
wrote:
All,
I have a function that returns data from my db as an array. To reduce the
times the script
has to access the db should I store the contents of the variable in a
session variable and
access it that way, or should I figure out how to set it and use it as a
static variable ?


The way to do it is to use the session. However, if this is good,
depends on the number of users and the way they use the data. The
session files will be stored on disk and with a wel spread use of your
database you might end up storing your whole database in session files
again.

HTH, Jochen
--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #2

P: n/a
> The way to do it is to use the session. However, if this is good,
depends on the number of users and the way they use the data. The
session files will be stored on disk and with a wel spread use of your
database you might end up storing your whole database in session files
again.


Thanks for your reply. I think I am going to test the session route. I have
been playing
with MySQLs Query Cache and had good luck w/it also.

I have enabled sessions for one of my modules. The problem I was having,
was, if someone
visits SECTION A, all the info for SECTION A is read and displayed. The user
then goes
to SECTION B and then back to SECTION A, however, the information is
constantly re-read
from the db, even though they were already there. By storing some of the
information in session
variables and retrieving them, I think I can increase the overall speed of
the site.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.