A
A
Artem00712017-07-18 11:57:19
PHP
Artem0071, 2017-07-18 11:57:19

How to temporarily close access to the database?

I have a table with points.
How to make it so that while one removes / replenishes points, the other person cannot do the same?
Example: there are points-A (points) and points-B (tiles)
They can be converted into each other. Both tables are limited in number (max points = 100, max tiles = 50000) throughout the database.
How to make it so that while one converts tiles to points, no one can do this (so that it does not happen that both exchange points and they suddenly become -10)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2017-07-18
@Artem0071

Locks in MySQL on Habré.
In short:

LOCK TABLES tiles, points WRITE;

-- тут конвертируем одно в другое

UNLOCK TABLES;

O
Optimus, 2017-07-18
Pyan @marrk2

Need to use transactions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question