Re: [PHP] LOCKS???
> On Nov 29, 2016, at 2:09 PM, Stuart Dallas <stuart@xxxxxxxx> wrote:
> On 29 November 2016 at 16:51:24, Tedd Sperling (tedd.sperling@xxxxxxxxx) wrote:
> As mentioned I’m pretty sure this is because you’re attempting to lock in one request and expect the lock to still be there in subsequent requests. This is fundamentally not how MySQL table locks work so you’ll need to implement your own mechanism.
I see now my that confusion in this matter stemmed from literature that tied LOCKs with sessions. I kept assuming, wrongfully so, that sessions meant php sessions. Even in correspondence on this list “sessions" were mentioned, which further supported my wrong assumption.
In any event, it now it makes sense that php sessions have nothing to do with MySQL sessions, whatever those are.
I thank you very much for your most knowledgeable answer.
I read over your “Job Queue” and the Memcache::add portion of the manual, but I don’t see how those would solve the problem of two users editing the same record at the same time. Perhaps these concepts are beyond me. I can’t implement something that I don’t fully understand.
I’ve never been afraid to show my ignorance, so let me pass my first-blush simple-to-me solution for you to consider and advise.
What about using a “busy” Table? I imagine it would work like this:
Let’s say a user accesses a page that allows editing of Tables A, B and C. However, before editing is permitted, the script checks the “busy Table” to see if those Tables (A,B,C) are currently being used.
If the Tables are not busy, then they are marked “busy" and the user is permitted to edit.
When the user finishes editing (i.e., leaves the page), then the script marks Tables A,B,C as "not busy”.
The process goes for all users — each script checks the busy Table to see if the Tables needed for their operation are in use. If the tables are open, then editing is permitted, if not then the user is denied and notified.
I can work out of the details of notifying users, but what do you think about this most-basic solution?
There must be something wrong with it for it is far too obvious to have not been considered before. So, what’s wrong with it?
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php