From 6649215e6135f13903f75c1e146f10b973aabd3a Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Wed, 5 May 2010 01:02:35 +0200 Subject: [PATCH] Use DELETE + INSERT statement wrapped in a transaction in Item::SaveRefundDataToDB() --HG-- branch : trunk --- src/game/Item.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 9927a936bc..cbb2766603 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -1057,15 +1057,11 @@ void Item::BuildUpdate(UpdateDataMapType& data_map) void Item::SaveRefundDataToDB() { - std::ostringstream ss; - ss << "INSERT INTO item_refund_instance VALUES("; - ss << GetGUIDLow() << ","; - ss << GetRefundRecipient() << ","; - ss << GetPaidMoney() << ","; - ss << GetPaidExtendedCost(); - ss << ")"; - - CharacterDatabase.Execute(ss.str().c_str()); + CharacterDatabase.BeginTransaction(); + CharacterDatabase.PExecute("DELETE FROM item_refund_instance WHERE item_guid = '%u'", GetGUIDLow()); + CharacterDatabase.PExecute("INSERT INTO item_refund_instance (`item_guid`,`player_guid`,`paidMoney`,`paidExtendedCost`)" + " VALUES('%u','%u','%u','%u')", GetGUIDLow(), GetRefundRecipient(), GetPaidMoney(), GetPaidExtendedCost()); + CharacterDatabase.CommitTransaction(); } void Item::DeleteRefundDataFromDB()