Re: AutoCommit does not work



On 8/22/06, Artem Harutyunyan <hartem@xxxxxxxxx> wrote:

Hi,

Consider, please, the following piece of code:
____________________________________________________________

{code fragment}
____________________________________________________________
It connects to the database, turns AutoCommit off, prepares the statement,
executes it, waits for 60 seconds and commits the statement.
Although I do not get any errors, it does not work as I expect. The
problem
is that I can see the new entry inside the table before $dbh->commit() is
called from the code. The same problem appears also when $dbh->begin_work
is used.


Hi Artem

I don't have much experience w/MySQL but my understanding with transactions
is that they only allow you roll back records within the transaction
block. A good example is an acct receivable;

BEGIN TRANSACTION
write a sales slip
write a journal record
write a check record
COMMIT
END TRANSACTION

If the "write a check record" operation failed, you'd do a "ROLLBACK" and
there'd be no sales or journal record because otherwise your DB would be all
screwed up.

In short, it souds like you're seeing what would be expected-
if you want the "$dbh->commit" to be some sort of "trigger" maybe you need
to re-think your application a little bit.

Hoping this helps

KC