Skip to content

Conversation

@JanJakes
Copy link
Member

@JanJakes JanJakes commented Dec 17, 2025

Extracting smaller chunks from #291 so we can review and merge them independently.

This PR includes the following changes:

  • Removed support for nested transactions. MySQL doesn't support them.
  • Implemented PDO-like APIs for start transaction, commit, and rollback.
  • The PDO-like APIs differ from an equivalent SQL command in that they always throw an exception in scenarios when a transaction was already started or not yet started (depending on the method), irrespective of the ATTR_ERRMODE setting.
  • Polyfill PDO::inTransaction() on PHP < 8.4, where it is not reliable (issue, PR).

@JanJakes JanJakes force-pushed the improve-transactions branch from 5ecb8f0 to aed66fe Compare December 17, 2025 16:49
@JanJakes JanJakes force-pushed the improve-transactions branch from dd87630 to 816e0b5 Compare December 17, 2025 18:45
@JanJakes JanJakes requested a review from adamziel December 17, 2025 18:59
* @var bool
*/
private $transaction_level = 0;
private $in_transaction = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice comment!

* @see https://bugs.php.net/bug.php?id=81227
* @see https://github.com/php/php-src/pull/14268
*/
return $this->in_transaction;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, nice.

* Execute the "BEGIN" or "START TRANSACTION" MySQL statement in SQLite.
*/
private function begin_user_transaction(): void {
// MySQL implicitly commits previous transaction when starting a new one.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL, really good digging

@adamziel adamziel merged commit 8bad00d into develop Dec 18, 2025
16 checks passed
@JanJakes JanJakes mentioned this pull request Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants