Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

SESSION variables or MYSQL queries

ajax mysql session session variable

  • Please log in to reply
3 replies to this topic

#1 Demodog

Demodog

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 14 April 2010 - 10:06 PM

Im making a web-rpg using PHP, MySQL and AJAX. As there are alot of variables used for player stats I wonder what is the best use for storing this while playing.

Right now Im using session variables while playing and when a task is done it is saved using mysql query update. I made it this way to get less queries to mysql. But I wonder which is less heavy for the server, writing session variables or making mysql updates?
  • 0

#2 webcodez

webcodez

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 143 posts

Posted 14 April 2010 - 11:22 PM

Hmm, I suppose mysql update queries but I don't see how sessions can replace update queries?
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#3 Demodog

Demodog

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 14 April 2010 - 11:50 PM

Well I have to store variables like health, strenght, room location etc somewhere to be able to create a game? Since players are in mysql database it has to be made an update to be able to save the stats but in the middle of a combat i can just update session variables and then save it to mysql after the fight is done. But if mysql is less resorcefull than writing session variables I might as well do mysql updates all the time.

well perhaps the best would be to store in-combat variables in javascript on client-side and then make a php call to update mysql after fight is done?
  • 0

#4 webcodez

webcodez

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 143 posts

Posted 15 April 2010 - 02:44 AM

Well, I suppose it'd be best to store stats that are dynamic, still changing while combat, into sessions and once combat is over and the defnite new stats are set, then update the database with those. But I'm not sure how your system works like and whether it's 'save' to do so, but atleast it takes less resources I believe.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?





Also tagged with one or more of these keywords: ajax, mysql, session, session variable

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download