Re: transactions
| From: | Adam Voigt | Date: | Mon, 29 Mar 2004 18:18:04 +0000 |
| Subject: | Re: transactions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-181685@lists.php.net to get a copy of this message | ||
I believe you can use transactions with InnoDB tables on MySQL, if this
is the case, a simple "BEGIN;" to begin your transaction, and a
"COMMIT;" to save all the changes, plus a "ROLLBACK;" to undo your
changes, should be sufficient.
On Mon, 2004-03-29 at 13:12, Matthew Oatham wrote:
> Hi,
>
> Is there an elegant way to recover from DB errors in MySQL using PHP, i.e. transactions and
> rolling back - basically I have an insert statement then an update statement. if the insert succeeds
> the update is run but if the update fails I want to undo the insert!
>
> Any suggestions, I guess I could get the last inserted row id and perform an sql delete but is
> there a more elegant way?
>
> Cheers
>
> Matt
--
Adam Voigt
adam@kotisprop.com