Search code examples
phparrayssuperglobals

PHP a custom SUPERGLOBAL array question


I was reading around, and I know it might be impossible to accomplish as I wished it would be but I am hoping there is a way, so here goes..

I have ID's of users and I have a count for each. I would like to be able to store those values in machine memory, and update the DB only once in a while, but absolutley not constantly. The page is being accessed from many users of course, and I want the array to stay relevant for each user, and update as necessary. (That's another reason I don't want to use the DB. Updates take time with indexed columns, right?)

an array such as : $my_superglobal_arr = ('1'=>304,'2'=>763,'6'=>12,'13'=>96); would have been perfect.

Any suggestions ?

Thanks !


Solution

  • Updates take time with indexed columns, right?

    Right. However, it depends. I'd strongly suggest you to go for the database first, get practical experience with updates and stuff, learn what particular amount of users you can call "many". And only then decide, if you really need your unusual setup, is it really necessary or just imaginary fantasies.

    Reading your other questions I only can say that to learn SQL first is a must.