I want to increment a field value safely using php and mysql.
-
What type of table/field must I use?
-
Is there a minimum version of MySQL I must use?
-
What’s the sql code for this, safe transaction for 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.
By what type of “table” I assume you mean storage engine. Anything that supports mutations (i.e. not “archive” or “black hole”)
Any numeric field will do (tinyint, int, float, etc). That said, there’s no special PHP code, just the SQL for incrementing the desired field:
If you want a transaction, then pack the above query into a transaction. As for MySQL version, I agree with @hsz – use the most current version possible.