Jump to content

SESSION variables or MYSQL queries

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Demodog

Demodog

    Newbie

  • Members
  • Pip
  • 9 posts
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?

#2
webcodez

webcodez

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
Hmm, I suppose mysql update queries but I don't see how sessions can replace update queries?

#3
Demodog

Demodog

    Newbie

  • Members
  • Pip
  • 9 posts
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?

#4
webcodez

webcodez

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
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.