1

Just a quick question - I am writing a PHP app that relies heavily on SQL databases. I am slightly worried that many users all accessing the same database will cause errors. If so, how can I overcome this, what can be done?

I am not sure how many users at the end of the day will be using it, not hundreds, but maybe 5 or 10 or even 20. And even then its unlikely that they will be updating at the EXACT same time, but still. Any thoughts?

8
  • What kind of errors are you expecting? Commented Jun 30, 2012 at 14:25
  • Well I just wonder what exactly happens if say two people update the SAME table at exactly the SAME time, surely that would produce an error? Commented Jun 30, 2012 at 14:27
  • Database servers handle concurrency access, reading/writing lock. Don't worry :) Commented Jun 30, 2012 at 14:30
  • so the solution.. is locking the tables? it seems to say that mySql is very good at preventing deadlocks? Commented Jun 30, 2012 at 14:33

1 Answer 1

1

MySQL Transactions is what you're looking for.
Then PHP PDO extension with its transactions management.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. Yeah but i'm saying, there seems to be two thoughts: one is, with mySql its not needed, it handles concurrency in its own way, and two, start locking your tables. So which is it?
Oh yes, it's needed with MySQL. By default it does not handle the concurrency the safe way. This is why transactions are provided where there's a need. There's another question on SO that may answer your question: mySQL Transactions vs Locking Table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.