DarkReaper Posted August 7, 2006 Share Posted August 7, 2006 Okay here is what i have in theory:A list of users.1. If a user clicks on another users name mysql inserts a row in the db saying that the users requests lets say "chat". 2. set a session var to the row id for the 1-st user.3. The second users sees that its attention is requested and clicks on the above users name, mysql update-s the row acccoudingly.4. set a session var to the row id for the 2-nd user5. Both users do their "chat".So far so good. But if both users click at the same time 2 rows get inserted (sometimes), usually the 2 sessions vars should be the same but they are not since mysql inserted 2 rows and the 2 vars are different, and the whole module gets to hell cous one user thinks it is "chatting" with someone as is the other, but in fact noone cant see the other couse the 2 rows in the db kinda kill functionallity.In short 2 rows exist but there should be only 1.Dont know if you understood me ...*notice: i say "chat" because i cant think of a word to fully classify it. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 7, 2006 Share Posted August 7, 2006 Well, short of locking the tables, it sounds you need to search for any existing pairings before you insert a fresh one. Quote Link to comment Share on other sites More sharing options...
DarkReaper Posted August 8, 2006 Author Share Posted August 8, 2006 I do it. Before each insertion i check if a row doesnt already exist ... and if doesnt exist insert it. But if they click at the same time 2 rows get inserted. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 8, 2006 Share Posted August 8, 2006 Then you'll have to lock the tables, or come up with some sort of unique key restrictions. Quote Link to comment 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.