Re: LOCK TABLES x COMMIT/ROLLBACK

From: Date: Fri, 16 Feb 2001 00:28:39 +0000
Subject: Re: LOCK TABLES x COMMIT/ROLLBACK
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-40030@lists.php.net to get a copy of this message
> can someone explain me how to use LOCK TABLES to subtitute transactions? > > I don't seem to get how this is possible... and I really need this... I > have a script that updates 4 tables at a time, and I have to be sure all of > them are updated, or NONE... I can only see this possible using > commit/rollback... I think the idea is this: 1. LOCK TABLES invovled. 2. Get the current values for all records you are about to change. 3. Attempt to make changes. 4. If any of the attempted changes fails, change back the ones that succeded.* 5. UNLOCK the TABLES * Or maybe UNLOCK lets you somehow rollback?... * And if your attempt to undo the changes you already did fails, you'll need some code to alert a human to straighten out the mess you've made after they fix whatever is making the code not work in the first place. You might have an easier time porting to a database that actually supports transactions... :-) http://postgresql.org Or, the latest version of MySQL, but I dunno how stable their transaction support is yet... -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#40030) next »