In general, don't put prepare statements inside of a loop. You can prepare once and use many times.my $updateDeduct = $DBH->prepare("UPDATE USER SET BALANCE = BALANCE - +? WHERE USERNAME = ?"); my $updateAdd = $DBH->prepare("UPDATE USER SET BALANCE = BALANCE + ? W +HERE USERNAME = ?"); $DBH->do("BEGIN"); # explicitly start a new transaction # this overrides autocommit setting $updateDeduct->execute($amount, $user); $updateAdd=>execute($amount, $user); $DBH->do("COMMIT"); #end transaction, this is the "expensive part" ti +mewise
In reply to Re: run 2 query mysql
by Marshall
in thread run 2 query mysql
by bigup401
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |