server wide persistant object?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
easydev
Forum Newbie
Posts: 4
Joined: Wed Mar 03, 2010 2:02 am

server wide persistant object?

Post by easydev »

Hello,

Anyone know is there a way that I can create an object, which persists across different users and sessions? Kind of like system wide global static variable ().

The reason is:
I have a data structure (think of category tree) that once constructed, should only be read only by all users in all sessions. Since constructing this object needs multiple database read, and the values are the same for all users (and it is not sensitive data), I guess it would make sense to construct it only once as "system wide" static object.

The only related method I can think of is: construct it and save it to the session, but this is for one session only, not what I want.

Any idea of it?

Thanks.
davex
Forum Contributor
Posts: 101
Joined: Sat Feb 27, 2010 4:10 pm
Location: Namibia

Re: server wide persistant object?

Post by davex »

Hi,

Hmm... the only way I can think to do this is to store it something i.e. a database table holding the constructed information which itself only needs one query to return.

Alternatively what about dynamic PHP - write a file containing the object with the data you want as a PHP file then include that into all scripts.

Cheers,

Dave.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: server wide persistant object?

Post by Eran »

Post Reply