feat(database): 实现数据库事务管理器- 新增 DatabaseTransactionsManager 类用于管理数据库事务#7544
Open
woweijun123 wants to merge 2 commits into
Open
feat(database): 实现数据库事务管理器- 新增 DatabaseTransactionsManager 类用于管理数据库事务#7544woweijun123 wants to merge 2 commits into
woweijun123 wants to merge 2 commits into
Conversation
woweijun123
commented
Sep 23, 2025
- 新增 DatabaseTransactionRecord 类用于记录事务信息
- 在 Connection 类中添加事务管理器的设置方法
- 在 db-connection 中自动注入事务管理器
- 实现事务开始、提交、回滚时的回调机制- 支持事务提交后的回调执行
- 支持事务回滚时的回调执行
- 优化事务层级管理逻辑 -修复事务丢失连接时的处理逻辑
- 新增 DatabaseTransactionRecord 类用于记录事务信息 - 在 Connection 类中添加事务管理器的设置方法 - 在 db-connection 中自动注入事务管理器 - 实现事务开始、提交、回滚时的回调机制- 支持事务提交后的回调执行 - 支持事务回滚时的回调执行 - 优化事务层级管理逻辑 -修复事务丢失连接时的处理逻辑
There was a problem hiding this comment.
Pull Request Overview
Implements a comprehensive database transaction management system with callback support for transaction lifecycle events. The PR introduces a centralized transaction manager that tracks transaction states and handles commit/rollback callbacks across nested transactions.
Key changes:
- Adds DatabaseTransactionsManager and DatabaseTransactionRecord classes for transaction state management
- Integrates transaction manager with database connections and the connection pool
- Implements callback mechanisms for post-commit and rollback scenarios
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/db-connection/src/Connection.php | Automatically injects transaction manager into database connections |
| src/database/src/DatabaseTransactionsManager.php | Core transaction manager with nested transaction support and callback handling |
| src/database/src/DatabaseTransactionRecord.php | Transaction record class for storing transaction state and callbacks |
| src/database/src/Connection.php | Adds transaction manager setter method |
| src/database/src/Concerns/ManagesTransactions.php | Integrates transaction manager calls into existing transaction methods |
| src/contract/src/ShouldDispatchAfterCommit.php | Marker interface for post-commit dispatch behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- 移除了 transactionsManager 属性访问时的可空操作符以避免潜在的调用异常 - 为 setTransactionManager 方法添加了类型提示和 PHPDoc 注释以增强代码健壮性 - 修改了 currentTransaction 的检查逻辑以确保连接存在时才进行事务回滚操作 - 更新了事务清理方法中的条件判断以防止对不存在的连接执行事务操作
Author
|
solved the problem |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.