Re: [PHP] LOCK TABLES x COMMIT/ROLLBACK

2001-02-15 Thread Richard Lynch

 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



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] LOCK TABLES x COMMIT/ROLLBACK

2001-02-15 Thread Nuno Silva

Richard Lynch wrote:

[snip...]

 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.*

you just can't relie on this... imagine that you stop apache just in the 
middle of the script... or imagine some power outage or some segfault... 
whatever... you manual "rollback" will not succeed :(

the only cenario that a lock can (securelly) replace a transaction is 
when you're UPDATING (_not_ inserting or deleting) only ONE table.




 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


yes, this would be my bet :)



 
 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
 
 
 
Regards,
Nuno Silva



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] LOCK TABLES x COMMIT/ROLLBACK

2001-02-12 Thread Christian Dechery

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...

thanks...

. Christian Dechery (lemming)
. http://www.tanamesa.com.br
. Gaita-L Owner / Web Developer


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]