Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

改进事务方法,支持嵌套事务提交 #490

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ThinkPHP/Library/Think/Db/Driver.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,16 @@ public function commit()
*/
public function rollback()
{
if ($this->transTimes > 0) {
if ($this->transTimes == 1) {
$result = $this->_linkID->rollback();
$this->transTimes = 0;
$this->transPdo = null;
if (!$result) {
$this->error();
return false;
}
} else {
$this->transTimes = $this->transTimes <= 0 ? 0 : $this->transTimes-1;
}
return true;
}
Expand Down
1 change: 0 additions & 1 deletion ThinkPHP/Library/Think/Model.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,6 @@ public function getTableName()
*/
public function startTrans()
{
$this->commit();
$this->db->startTrans();
return;
}
Expand Down