Hi!
I am sure someone already asked it, but I could not find definitive clues...
I am runnig an update from php to mysql. I add or substract a given 'price' from a column called 'balance'. Value is int.
add:
UPDATE tableX SET balance = balance + price WHERE ID = Y;
substract:
UPDATE tableX SET balance = balance - price WHERE (balance - price > -1) AND (ID = Y) ;
Now. A lot of PHP threads will be doing this at the same time. Is this like transactionally safe? I mean the server has to check the balance then update it. Can another thread do an update between this two things, or not?
I forgot to mention, this will be running on NDB. The cluster database engine.
Yours Sincererly
Laszlo Balogh
I am sure someone already asked it, but I could not find definitive clues...
I am runnig an update from php to mysql. I add or substract a given 'price' from a column called 'balance'. Value is int.
add:
UPDATE tableX SET balance = balance + price WHERE ID = Y;
substract:
UPDATE tableX SET balance = balance - price WHERE (balance - price > -1) AND (ID = Y) ;
Now. A lot of PHP threads will be doing this at the same time. Is this like transactionally safe? I mean the server has to check the balance then update it. Can another thread do an update between this two things, or not?
I forgot to mention, this will be running on NDB. The cluster database engine.
Yours Sincererly
Laszlo Balogh