MyISAM Transaction sorun

0 Cevap php

İşte sorundur. Ben MySQL MyISAM tabloları çift tablolar var. Ve ayrıca ben bir başka bağımlı birkaç sorguları var. Bu tür bir şey:

CREATE TABLE users (
  name varchar(255) DEFAULT NULL PRYMARY KEY,
  money int(10) unsigned DEFAULT NULL
);
INSERT INTO users(name, money) VALUES('user1', 700);
INSERT INTO users(name, money) VALUES('user2', 200);

Ben anouther 1 kullanıcıdan para aktarmak gerekiyor

<?php
$query1 = "UPDATE users SET money=money-50 WHERE name = 'user1'";
$query2 = "UPDATE users SET money=money+50 WHERE name = 'user2'";

The problem is if connection breaks between these two queries, the money just get lost, first user looses them, the other one doesn't get them. I could use InnoDB or BDB to start transaction, and rollback both queries on error in any of them, but still i have this asignment for MyISAM. How this problem normally get solved?

0 Cevap