I want to increment a col in a table and if value of col after increment is equal to 15, then do another job. I can do this by two query like this:
"update my_table set my_col=my_col+1 where my_col<15;"
I can get id of updated row (updated_id) and use it:
"select id from my_table where my_col=15 and id=updated_id limit 1;"
but it is possible that another query update the row before execute select statement. how can I execute this two query atomically and prevent executing another query until it finishes (with php mysql PDO)?