3 namespace Org\Mxchange\CoreFramework\Database\Backend;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Database\Backend\DatabaseBackend;
7 use Org\Mxchange\CoreFramework\Generic\FrameworkException;
8 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
11 * An abstract database access class for handling database I/O requests
13 * @see DatabaseBackend - An interface for database backends
14 * @author Roland Haeder <webmaster@shipsimu.org>
16 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
17 * @license GNU GPL 3.0 or any newer version
18 * @link http://www.shipsimu.org
20 * This program is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 abstract class BaseDatabaseBackend extends BaseFrameworkSystem implements DatabaseBackend {
34 // Constants for exceptions
35 const EXCEPTION_SQL_QUERY = 0x140;
37 // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!)
38 const DB_CODE_TABLE_MISSING = 0x100;
39 const DB_CODE_TABLE_UNWRITEABLE = 0x101;
40 const DB_CODE_DATA_FILE_CORRUPT = 0x102;
43 const RESULT_OKAY = 'ok';
46 * Last thrown exception or NULL if all is fine
48 private $lastException = NULL;
51 * Protected constructor
53 * @param $className Name of the class
56 protected function __construct (string $className) {
57 // Call parent constructor
58 parent::__construct($className);
62 * Getter for last exception
64 * @return $lastException Last thrown exception
66 public final function getLastException () {
67 return $this->lastException;
71 * Setter for last exception
73 * @param $lastException Last thrown exception
76 public final function setLastException (FrameworkException $exceptionInstance) {
77 $this->lastException = $exceptionInstance;
81 * Reset the last exception instance. This should be done after a "query"
82 * was completed without any errors.
86 protected final function resetLastException () {
87 $this->lastException = NULL;
91 * Removes non-public data from given array.
93 * @param $data An array with possible non-public data that needs to be removed.
94 * @return $data A cleaned up array with only public data.
96 public abstract function removeNonPublicDataFromArray (array $data);