I've not worked with InnoDb, but given that the web is a stateless space 
and all kinds of things can happen, I'd be very reluctant to lock a record 
until the very moment I'm updating it. In other words, when I have my batch 
of updates and inserts ready to go, then I'd begin by transaction, execute 
them, and do a commit or a rollback.

Cdn$ .02   - Miles Thompson

At 04:59 PM 8/29/2002 +0200, Geranium wrote:
>I could use some practical tips on doing transactions with InnoDB
>tables in MySQL.
>I want to grab and lock a record and do a whole load of related stuff,
>then make sure everything is updated in a consistent way, something
>like this skeleton:
>SELECT * from blah WHERE something=n FOR UPDATE //Grab and lock a record
>SELECT * from t1, t2 where a=1 ...
>INSERT blah...
>UPDATE something else...
>if ($allok)
>I don't quite get what I need to do to make sure these are all regarded
>as part of the same transaction. Does the transation apply to all
>queries made between the begin and commit (I assume so)? What happens
>when I have another process doing the same thing at the same time?
>Do I need to keep the result value I get from the begin query and
>somehow use it for the commit at the end so MySQL knows they are two
>ends of the same transaction? Or does MySQL somehow track that for me -
>i.e. can there only be one transaction in progress per connection?
>I'm finding the MySQL docs are extremely dry and somewhat short on
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to