Re: Update multiple tables
| From: | Ramil Sagum | Date: | Thu, 26 Aug 2004 05:21:38 +0000 |
| Subject: | Re: Update multiple tables | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-35890@lists.php.net to get a copy of this message | ||
On Wed, 25 Aug 2004 22:08:03 -0700 (PDT), Khalid Judeh
<khjudeh@yahoo.com> wrote:
> Hello,
> I have a script that make changes to the database in more than one sql statement, as i need to
> update more than one table at the same time, I want to know if there is a method where all of those
> changes are committed, or rolled back if some error occured(lets say in the last sql statement).
> thanks
Use transactions :
BEGIN TRANSACTION
...sql statements...
COMMIT
or
ROLLBACK
The implementation varies a little. Check out the documentation/manual
of your database server for "transactions".
(PHP also has built-in functions for transactions such as
mysqli_commit(), mysqli_rollback() and mysqli_autocommit() for
mysqli.)
HTH.
----
ramil