From f91e2ec7b2e6f712c265b4bea05ef1a95b162ac5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= <rdoursenaud@gpcsolutions.fr>
Date: Sat, 15 Mar 2014 06:17:12 +0100
Subject: [PATCH] Database: factorized begin()
---
htdocs/core/db/DoliDB.class.php | 26 ++++++++++++++++++++++++++
htdocs/core/db/mysql.class.php | 27 ---------------------------
htdocs/core/db/mysqli.class.php | 27 ---------------------------
htdocs/core/db/sqlite.class.php | 27 ---------------------------
4 files changed, 26 insertions(+), 81 deletions(-)
diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php
index a246bb6f15c..054e2d8f0bc 100644
--- a/htdocs/core/db/DoliDB.class.php
+++ b/htdocs/core/db/DoliDB.class.php
@@ -99,6 +99,32 @@ abstract class DoliDB implements Database
return $this->lasterrno;
}
+ /**
+ * Start transaction
+ *
+ * @return int 1 if transaction successfuly opened or already opened, 0 if error
+ */
+ function begin()
+ {
+ if (! $this->transaction_opened)
+ {
+ $ret=$this->query("BEGIN");
+ if ($ret)
+ {
+ $this->transaction_opened++;
+ dol_syslog("BEGIN Transaction",LOG_DEBUG);
+ dol_syslog('',0,1);
+ }
+ return $ret;
+ }
+ else
+ {
+ $this->transaction_opened++;
+ dol_syslog('',0,1);
+ return 1;
+ }
+ }
+
/**
* Define sort criteria of request
*
diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php
index 7ebb8f84c16..fc6a59726cb 100644
--- a/htdocs/core/db/mysql.class.php
+++ b/htdocs/core/db/mysql.class.php
@@ -287,33 +287,6 @@ class DoliDBMysql extends DoliDB
return false;
}
-
- /**
- * Start transaction
- *
- * @return int 1 if transaction successfuly opened or already opened, 0 if error
- */
- function begin()
- {
- if (! $this->transaction_opened)
- {
- $ret=$this->query("BEGIN");
- if ($ret)
- {
- $this->transaction_opened++;
- dol_syslog("BEGIN Transaction",LOG_DEBUG);
- dol_syslog('',0,1);
- }
- return $ret;
- }
- else
- {
- $this->transaction_opened++;
- dol_syslog('',0,1);
- return 1;
- }
- }
-
/**
* Validate a database transaction
*
diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php
index f7bb2c3515b..a8545532aba 100644
--- a/htdocs/core/db/mysqli.class.php
+++ b/htdocs/core/db/mysqli.class.php
@@ -291,33 +291,6 @@ class DoliDBMysqli extends DoliDB
return false;
}
-
- /**
- * Start transaction
- *
- * @return int 1 if transaction successfuly opened or already opened, 0 if error
- */
- function begin()
- {
- if (! $this->transaction_opened)
- {
- $ret=$this->query("BEGIN");
- if ($ret)
- {
- $this->transaction_opened++;
- dol_syslog("BEGIN Transaction",LOG_DEBUG);
- dol_syslog('',0,1);
- }
- return $ret;
- }
- else
- {
- $this->transaction_opened++;
- dol_syslog('',0,1);
- return 1;
- }
- }
-
/**
* Validate a database transaction
*
diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php
index aae07cce299..0bcc3308c1d 100644
--- a/htdocs/core/db/sqlite.class.php
+++ b/htdocs/core/db/sqlite.class.php
@@ -415,33 +415,6 @@ class DoliDBSqlite extends DoliDB
return false;
}
-
- /**
- * Start transaction
- *
- * @return int 1 if transaction successfuly opened or already opened, 0 if error
- */
- function begin()
- {
- if (! $this->transaction_opened)
- {
- $ret=$this->query("BEGIN");
- if ($ret)
- {
- $this->transaction_opened++;
- dol_syslog("BEGIN Transaction",LOG_DEBUG);
- dol_syslog('',0,1);
- }
- return $ret;
- }
- else
- {
- $this->transaction_opened++;
- dol_syslog('',0,1);
- return 1;
- }
- }
-
/**
* Validate a database transaction
*
--
GitLab