MySQL Forums
Forum List  »  PHP

Re: Duplicate values being created
Posted by: Peter Brawley
Date: January 25, 2018 03:09PM

Obviously if it's not a PK or unique key, nothing in the logic you've shown prevents value dupes. If the table has an auto_increment PK, use that for ordering. Otherwise implement logic to prevent duplicates, eg populate a table imgord( ord int unsigned primary key, used bool ), and in the insert transaction find the smallest imgord.ord for which used=0, lock it for update, set it=1, and use that value in ext_images.

Options: ReplyQuote


Subject
Written By
Posted
Re: Duplicate values being created
January 25, 2018 03:09PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.