PHP/MYSQL - Rollback or list last rows affected by update

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cjkeane
Forum Contributor
Posts: 217
Joined: Fri Jun 11, 2010 1:17 pm

PHP/MYSQL - Rollback or list last rows affected by update

Post by cjkeane »

Hi everyone,

I performed a MYSQL update using php, however the update query was incorrect and updated the wrong rows.

Is it possible to rollback the update query or at least SELECT the rows performed by the last update query so I can tell which rows i need to change back?

thanks.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHP/MYSQL - Rollback or list last rows affected by updat

Post by Christopher »

You can manually SELECT the data from same rows before they will be UPDATEd -- just use the same WHERE clause. You can also use transactions and roll back the changes if there are problems. See the MySQL documentation for transactions.
(#10850)
Post Reply