Which version of MySQL?  In the CREATE TABLE statement for members, did you
specify the table type that uses transactions?  (Can't remember what it is right
this second.)  Does your actual code execute more than one statement inside the
transaction?  If not, there's not much point to using it.

The canonical example for using transactions looks something like this (after
setting AutoCommit to 0 and preparing $sth):

     eval {
          $sth->execute($pay, $user);
          # other SQL statements
          $dbh->commit;
     };
     if ($@) {
          $dbh->rollback;
          # other error handling: unlock the table, log a warning, etc.
     }





[EMAIL PROTECTED] on 08/14/2001 02:40:35 PM

To:   [EMAIL PROTECTED]
cc:    (bcc: Wesley Sheldahl/Lex/Lexmark)
Subject:  FW: auto commit


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 14, 2001 12:49
To: [EMAIL PROTECTED]
Subject: Re: auto commit


On Tue, 14 Aug 2001 12:26:39 -0400, [EMAIL PROTECTED]   wrote:

>>You don't mention which database, which might make a difference.

MySQL.

>>The finish() after the UPDATE won't do what you think it will.  It should
>>only be used after a SELECT query.  The cheetah book talks about it on p.
>>117.

thanks, didn't know that. :)

>>-----Original Message-----
>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>>Sent: Tuesday, August 14, 2001 11:47
>>To: [EMAIL PROTECTED]
>>Cc: [EMAIL PROTECTED]
>>Subject: Re: auto commit
>>
>>
>>Here is a very trimmed down sample snip:
>>
>>
>>$dbh->do('LOCK TABLE members WRITE');
>>$dbh->do('begin');
>>
>>$query = qq|UPDATE members SET payment = ? WHERE username = ?|;
>>$sth = $dbh->prepare($query);
>>$sth->execute($pay,$user);
>>$sth->finish() if $sth;
>>
>>$dbh->do('commit');
>>$dbh->do('UNLOCK TABLE');
>>$dbh->disconnect() if $dbh;
>>
>>
>>>>On Tue, 14 Aug 2001 11:18:33 -0400, [EMAIL PROTECTED]   wrote:
>>
>>>>Can you provide some code?
>>>>
>>>>-----Original Message-----
>>>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>>>>Sent: Tuesday, August 14, 2001 10:02
>>>>To: [EMAIL PROTECTED]
>>>>Subject: auto commit
>>>>
>>>>
>>>>Hello All,
>>>>
>>>>When setting AutoCommit => 0, with transactions, does anything else need
>>to
>>>>be
>>>>set to disable Autocommit? It seems that the Autocommit => 0 is being
>>>>ignored in
>>>>our script. If it's set to '0' is still seems to process the queries
with
>>or
>>>>without invoking the $dbh->{'commit'} and no error is generated?
>>>>
>>>>I'm I missing something. ??
>>>>
>>>>THX's
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Mike(mickalo)Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
Tel: 1(225)686-2002
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=




Reply via email to