Simultaneous Access API Rest

0

I have a PHP application that receives json from another application and writes them to the MySQL database.      Before recording the data, I check the bank to see if the record has not been previously recorded.      However, when I check the database now this afternoon, I come across two identical records. What could have happened? Was the client application so fast and before the first was recorded in the bank the second was also being processed? How can I protect myself from this?      My Apache configuration is by default.

Thank you very much.

    
asked by anonymous 07.06.2016 / 22:34

1 answer

1

Database managers can avoid multiple access. Of course it is possible that after a select an insert of another query is done. To make it more reliable you can do a select transaction followed by insert. And another, if two records can not be equal, should be a restriction on the database.

    
08.06.2016 / 01:05