I'm a new MySQL user. I create an InnoDB database system.
In my case, I need lock rows if select for update is use. But even if I've done many search I don't understand how to lock row for all users if this row is loaded by one user.
I use php to connect on mySQL database.
Can you help me to solve that?
MySQL will do the row-locking for you automatically.
There should be no need to do the row locking yourself.
However if you insist on doing this, you can use a select ... for update
.
See: http://dev.mysql.com/doc/refman/5.0/en/innodb-locking-reads.html
SELECT counter_field FROM child_codes FOR UPDATE;
UPDATE child_codes SET counter_field = counter_field + 1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With