* [misc] Check if is in transaction before commit or rollback.

This commit is contained in:
liugang
2025-08-06 15:22:14 +08:00
committed by tianshujie
parent eeba755e36
commit fc1ba52f2d
3 changed files with 8 additions and 12 deletions
+6 -10
View File
@@ -496,7 +496,7 @@ class baseDAO
*/
public function begin()
{
$this->dbh->beginTransaction();
if(!$this->dbh->inTransaction()) $this->dbh->beginTransaction();
}
/**
@@ -520,7 +520,7 @@ class baseDAO
*/
public function rollBack()
{
$this->dbh->rollBack();
if($this->dbh->inTransaction()) $this->dbh->rollBack();
}
/**
@@ -532,7 +532,7 @@ class baseDAO
*/
public function commit()
{
$this->dbh->commit();
if($this->dbh->inTransaction()) $this->dbh->commit();
}
/**
@@ -1171,8 +1171,7 @@ class baseDAO
return 0;
}
$inTransaction = $this->inTransaction();
if(!$inTransaction) $this->begin();
$this->begin();
foreach($indexes as $fields)
{
@@ -1191,11 +1190,8 @@ class baseDAO
$result = $this->insert($table)->data($processedData)->exec();
if(!$inTransaction)
{
if(!$result) $this->rollback();
$this->commit();
}
if(!$result) $this->rollback();
$this->commit();
return $result;
}
+1 -1
View File
@@ -90,7 +90,7 @@ class task extends control
if(dao::isError())
{
if($this->dao->inTransaction()) $this->dao->rollBack();
$this->dao->rollBack();
return $this->send(array('result' => 'fail', 'message' => dao::getError()));
}
+1 -1
View File
@@ -1020,7 +1020,7 @@ class taskModel extends model
$this->dao->insert(TABLE_TASKSPEC)->data($taskSpec)->autoCheck()->exec();
if(dao::isError()) return false;
if($this->dao->inTransaction()) $this->dao->commit();
$this->dao->commit();
if($createAction)
{