* [misc] Check if is in transaction before commit or rollback.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user