For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > May 2005 > Re: [PHP-DB] multiple queries, one transaction - REWORDED









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] multiple queries, one transaction - REWORDED
Andrés G. Montañez

2005-05-26, 8:56 pm

Crate an Array, where the Key is the ItemId, and the value is the ItemQty.
If the client want to delete an the item, unset the key, if the client
wont to add or remove an item quantity, just change the value.

Then when the items and quantities are correct, just=20
<start transaction>
<begin foreach>
If (! (INSERT ..... (order, ItemID (the array key), ItemQty (the array
value of the key))...))
<rollback transaction>
<break>
<end foreach>
<commit transaction>

So if the insert is failed, you rollbackit.
No need for a DELETE

--=20
Atte, Andr=E9s G. Monta=F1ez
T=E9cnico en Redes y Telecomunicaciones
Montevideo - Uruguay
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com