forked from doctrine/doctrine1
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix(migrations) Handle transaction on PDO and PHPv8
- Loading branch information
Showing
3 changed files
with
42 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/** | ||
* Helper for transactions handling. | ||
* | ||
* @author Kyle McGrogan <[email protected]> | ||
*/ | ||
final class Doctrine_TransactionHelper | ||
{ | ||
/** | ||
* Execute a commit on the given connection, only if a transaction already started. | ||
*/ | ||
public static function commitIfInTransaction(Doctrine_Connection $connection): void | ||
{ | ||
$handler = $connection->getDbh(); | ||
|
||
// Attempt to commit while no transaction is running results in exception since PHP 8 + pdo_mysql combination | ||
if ($handler instanceof PDO && !$handler->inTransaction()) { | ||
return; | ||
} | ||
|
||
$connection->commit(); | ||
} | ||
} |