Bruce,

----- Original Message ----- 
From: ""bruce"" <[EMAIL PROTECTED]>
Newsgroups: mailing.database.mysql
Sent: Sunday, July 13, 2003 11:32 PM
Subject: MySql Rollback in PHP within a website


> Hey...
>
> I have a question. I need to be able to try to perform a database update,
> but if it doesn't succeed, I need to be able to rollback the changes, and
to
> inform the user that the changes didn't succeed.
>
> I've looked at the MySql site, and can see somewhat how the
Commit/RollBack
> functions work. However, I'm not sure how to create the required PHP code
to
> implement this kind of process...
>
> Basically I need to:
>
> Create query...
> Perform Update on the table(s)
> Perform my check(s)
> If the checks fail
> alert user
> rollback updates
> else
> success
>
> It's my understanding that I need to somehow set "START TRANSACTION" prior
> to beginning the update. But I'm not sure how to do that within the PHP
> code... Nor am I sure if there's something else I need to do...
>
> Any examples/hints/sample code will be appreciated. Thanks for any
> assistance!

can you simply execute in PHP

BEGIN

and

ROLLBACK

as normal SQL command strings? Like you would execute INSERT INTO ...

It is better to send these commands to the mysqld server as normal SQL
strings, because in old versions of MySQL middleware special 'commit' etc.
function calls may not be implemented.

Is it in PHP so that the mysqld connection is always closed if you move to
another HTML page? When mysqld ends a connection it automatically rolls back
the current uncommitted transaction.

> Regards,
>
> Bruce
> [EMAIL PROTECTED]
> (925) 866-2790

Best regards,

Heikki Tuuri
Innobase Oy
http://www.innodb.com
Transactions, foreign keys, and a hot backup tool for MySQL
Order MySQL technical support from https://order.mysql.com/



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to