cliftonbazaar Posted August 5, 2011 Share Posted August 5, 2011 This isn't a question, more of a request to be pointed in the right direction. I have a program which runs a sports game (cricket), at the moment the database is updated every 5 seconds so each game can be updated in (nearly) real time. The problem I see is that when players are updating their team or making changes during the '5 second update'- can I make the player changes wait until the 5 second update has finished? In other words, how do I lock the database (or lock certain rows) while it does it's update but also make sure that players changes wait in a queue until the update is finished and are simply not discarded? I hope this makes sense Quote Link to comment https://forums.phpfreaks.com/topic/243896-two-differant-parts-of-the-code-accessing-the-same-database-at-the-same-time/ Share on other sites More sharing options...
kickstart Posted August 5, 2011 Share Posted August 5, 2011 Hi Table locking should do the job for you:- http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html The other operations should just wait. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/243896-two-differant-parts-of-the-code-accessing-the-same-database-at-the-same-time/#findComment-1252469 Share on other sites More sharing options...
fenway Posted August 5, 2011 Share Posted August 5, 2011 Since it might be possible to leave a table "locked" inadvertently, it might be preferable to use a flag on the row to indicate it's "mid-update". Quote Link to comment https://forums.phpfreaks.com/topic/243896-two-differant-parts-of-the-code-accessing-the-same-database-at-the-same-time/#findComment-1252515 Share on other sites More sharing options...
cliftonbazaar Posted August 5, 2011 Author Share Posted August 5, 2011 Thanks Kickstart for the link, am reading that now. Fenway, what term should I search for in order to find more information on flagging a row? Quote Link to comment https://forums.phpfreaks.com/topic/243896-two-differant-parts-of-the-code-accessing-the-same-database-at-the-same-time/#findComment-1252541 Share on other sites More sharing options...
fenway Posted August 5, 2011 Share Posted August 5, 2011 Well, that depends on what kind of "updates" you're talking about. Quote Link to comment https://forums.phpfreaks.com/topic/243896-two-differant-parts-of-the-code-accessing-the-same-database-at-the-same-time/#findComment-1252723 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.