Search code examples
phpmysqldata-integrity

how to handle multi-users connections with my php script?


If I write a script php writing in a database,
should I handle the locking of the database to avoid conflicts between users ?

Or is this issue handled by the web server ?


Solution

  • Locks are handled implicitly by MySQL. You generally don't have to worry about issuing the actual lock statements, but you must be aware of how your updates are affecting other users.

    InnoDB supports row level locking, so updates may be unobtrusive, assuming you're using a primary key.