diff --git a/htdocs/lib/mysql.lib.php b/htdocs/lib/mysql.lib.php index 1d4675e0222..8766843c6d9 100644 --- a/htdocs/lib/mysql.lib.php +++ b/htdocs/lib/mysql.lib.php @@ -326,7 +326,7 @@ class DoliDb function commit() { - if ($this->transaction_opened==1) + if ($this->transaction_opened<=1) { $ret=$this->query("COMMIT"); if ($ret) $this->transaction_opened=0; @@ -346,7 +346,7 @@ class DoliDb function rollback() { - if ($this->transaction_opened==1) + if ($this->transaction_opened<=1) { $ret=$this->query("ROLLBACK"); $this->transaction_opened=0; @@ -354,6 +354,7 @@ class DoliDb } else { + $this->transaction_opened--; return 1; } } diff --git a/htdocs/lib/pgsql.lib.php b/htdocs/lib/pgsql.lib.php index b206a533088..0282240a82c 100644 --- a/htdocs/lib/pgsql.lib.php +++ b/htdocs/lib/pgsql.lib.php @@ -307,7 +307,7 @@ class DoliDb */ function commit() { - if ($this->transaction_opened==1) + if ($this->transaction_opened<=1) { $ret=$this->query("COMMIT;"); if ($ret) $this->transaction_opened=0; @@ -326,7 +326,7 @@ class DoliDb */ function rollback() { - if ($this->transaction_opened==1) + if ($this->transaction_opened<=1) { $ret=$this->query("ROLLBACK;"); $this->transaction_opened=0; @@ -334,6 +334,7 @@ class DoliDb } else { + $this->transaction_opened--; return 1; } }