Re: Allow commit() without transaction?

From: Date: Mon, 12 Apr 2021 15:52:32 +0000
Subject: Re: Allow commit() without transaction?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-114040@lists.php.net to get a copy of this message
>
>
> I think it is really nice that commit() throws for inactive
> transactions. Code paths that mess up your transactions will not go
> unnoticed that easily.
>

+1. I've always found this behaviour in MySQL very surprising and error
prone (BEGIN; BEGIN; COMMIT; COMMIT; => no errors), and I'm actually very
happy to see this solved at PDO level.

IMO if someone relies on commit() not throwing if there is no active
transaction, they should be the one doing the extra check: if
($pdo->inTransaction()) $pdo->commit().

— Benjamin


Thread (6 messages)

« previous php.internals (#114040) next »