From 5426db63ff2259c623a4bac31ffb8006a2db4d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Tue, 10 Sep 2013 12:29:55 +0200 Subject: [PATCH] Added an abstract DolibDB class --- htdocs/core/db/DoliDB.class.php | 65 +++++++++++++++++++++++++++++++++ htdocs/core/db/mssql.class.php | 3 +- htdocs/core/db/mysql.class.php | 3 +- htdocs/core/db/mysqli.class.php | 3 +- htdocs/core/db/pgsql.class.php | 3 +- htdocs/core/db/sqlite.class.php | 3 +- 6 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 htdocs/core/db/DoliDB.class.php diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php new file mode 100644 index 00000000000..f9ce1884a0c --- /dev/null +++ b/htdocs/core/db/DoliDB.class.php @@ -0,0 +1,65 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/db/dolidb.class.php + * \brief Class file to manage Dolibarr database access + */ + +/** + * Class to manage Dolibarr database access + */ +abstract class DoliDB +{ + //! Database handler + public $db; + //! Database type + public $type; + //! Database label + static $label; + //! Charset used to force charset when creating database + public $forcecharset; + //! Collate used to force collate when creating database + public $forcecollate; + //! Min database version + static $versionmin; + //! Resultset of last query + private $_results; + //! 1 if connected, else 0 + public $connected; + //! 1 if database selected, else 0 + public $database_selected; + //! Selected database name + public $database_name; + //! Database username + public $database_user; + //! >=1 if a transaction is opened, 0 otherwise + public $transaction_opened; + //! Last successful query + public $lastquery; + //! Last failed query + public $lastqueryerror; + //! Last error message + public $lasterror; + //! Last error number + public $lasterrno; + + public $ok; + public $error; +} + diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 5053a359e9b..597cc8e7c53 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -23,11 +23,12 @@ * \brief Fichier de la classe permettant de gerer une base mssql */ +require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php'; /** * Classe de gestion de la database de dolibarr */ -class DoliDBMssql +class DoliDBMssql extends DoliDB { //! Database handler var $db; diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 0ec729102ec..ce1f6b9e3ea 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -24,11 +24,12 @@ * \brief Class file to manage Dolibarr database access for a Mysql database */ +require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php'; /** * Class to manage Dolibarr database access for a Mysql database */ -class DoliDBMysql +class DoliDBMysql extends DoliDB { //! Database handler var $db; diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 1ea54387c22..8a653fc6579 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -24,11 +24,12 @@ * \brief Class file to manage Dolibarr database access for a Mysql database */ +require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php'; /** * Class to manage Dolibarr database access for a Mysql database */ -class DoliDBMysqli +class DoliDBMysqli extends DoliDB { //! Database handler var $db; diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 255b2c6e66f..cffcee3acd9 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -27,11 +27,12 @@ * \brief Fichier de la classe permettant de gerer une base pgsql */ +require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php'; /** * Class to drive a Postgresql database for Dolibarr */ -class DoliDBPgsql +class DoliDBPgsql extends DoliDB { //! Database handler var $db; diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index 631496b3998..5ef26e52885 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -24,11 +24,12 @@ * \brief Class file to manage Dolibarr database access for a Sqlite database */ +require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php'; /** * Class to manage Dolibarr database access for a Sqlite database */ -class DoliDBSqlite +class DoliDBSqlite extends DoliDB { //! Database handler var $db;