Link to home
Start Free TrialLog in
Avatar of Torquil Beavis
Torquil BeavisFlag for Canada

asked on

Multiple table users, one user deletes a record ..

Using PHP/Mysqli (InnoDB):
How can one user who legitimately deletes a MySqli record from a table not create an issue with the other users who are also using the same record from the same table and who may try to update that record?
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

Three users load up the same record.  They all see the same thing.

User 1 deletes a phone number, and saves the change.  Users 2 and 3 won't notice anything until they refresh the record.

User 2 refreshes the record and sees the phone number is deleted.  User 3 still sees nothing.

User 3 saves the record (including the original phone number).  Users 1 and 2 won't notice anything until they refresh the record.

User 1 refreshes the record and is confused as to how the phone number he just deleted got put back.

Etc.
Avatar of Torquil Beavis

ASKER

Exactly, Paul.
Now imagine user 1 deletes the whole record, users 2 and 3 enter changes on their screens and submit. There's no longer any record.  This will cause the script to direct the action to an error.
Am I right in saying that there's no standard way to handle this (via temporary locks, etc)?
ASKER CERTIFIED SOLUTION
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's in line with my thinking.
Perhaps what I can do is mark the record 'deleted' then when another user accesses the record it could show a 'deleted' flag yet allow the user to resurrect the file to make changes (this would be legitimate in the particular script that I'm working on, but not others). The  script could then re-status the record to 'updated' from 'deleted'.
Please let me know if this makes your hair curl due to my ignorance of any potential disaster doing this ;)
Not at all.  I'd say it's standard practice to "flag as deleted", then clean up when you know the data is no longer needed.   I *would* suggest you limit the number of people who can "unflag as deleted".
Indeed. They are  site admins.
Thank you.
Exactly what I was looking for.
Cheers Paul.
Happy to help.  Thanks for the points.