I want to do the following.
- Lock a row in the Users table for USER ID 10
- SELECT the number of credits the User has
- Update the number of credits the user has
- Release the lock
How do I lock specific table rows using PHP and MYSQL?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you are using the InnoDB engine you can use row locking by starting and committing a transaction as described in the manual: http://dev.mysql.com/doc/refman/5.0/en/innodb-lock-modes.html
See also: http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-transactions.html