twsowerby Posted April 28, 2010 Share Posted April 28, 2010 I ahve a call referral system that allows a user to log in and view referral records one at a time. The user looks at the record, makes a call, adds a note and clicks submit. The record is then updated. I am fast approaching a situation where I will have more than one user. Given the way the system retrieves records it is possible that two people using the system at the same time may be shown the same record and attempt to edit the same record at the same time. To get around this I was planning on implementing a random selection function. The function would randomly select a record and display it. Upon selection, a 'currently being edited' marker would be placed against that record. The next time a user calls the random selection function, it will do a check to see if the 'currently being edited' marker exists for that record. If it does then call the random select function again and so on until it gets one with no marker. Is there a better way of doing this? Cheers! Link to comment https://forums.phpfreaks.com/topic/200015-users-not-being-able-to-edit-page-at-the-same-time/ Share on other sites More sharing options...
ignace Posted April 28, 2010 Share Posted April 28, 2010 Add a field checkin (boolean DEFAULT FALSE) then when a user edits a page (checkin = TRUE) when a new user wants to retrieve a page query: SELECT * FROM table WHERE checkin = FALSE ORDER BY rand() LIMIT 1 Link to comment https://forums.phpfreaks.com/topic/200015-users-not-being-able-to-edit-page-at-the-same-time/#findComment-1049780 Share on other sites More sharing options...
twsowerby Posted April 28, 2010 Author Share Posted April 28, 2010 Excellent thanks, thats pretty much what I figured, just wondered of there was a different way that might be better. Cheers Link to comment https://forums.phpfreaks.com/topic/200015-users-not-being-able-to-edit-page-at-the-same-time/#findComment-1049784 Share on other sites More sharing options...
ignace Posted April 28, 2010 Share Posted April 28, 2010 thats pretty much what I figured Not entirely: The next time a user calls the random selection function, it will do a check to see if the 'currently being edited' marker exists for that record. If it does then call the random select function again and so on until it gets one with no marker. My method avoids this second call. Link to comment https://forums.phpfreaks.com/topic/200015-users-not-being-able-to-edit-page-at-the-same-time/#findComment-1049788 Share on other sites More sharing options...
twsowerby Posted April 28, 2010 Author Share Posted April 28, 2010 Ah yes I see the difference now. Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/200015-users-not-being-able-to-edit-page-at-the-same-time/#findComment-1049791 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.