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 - 2017 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 // Result array indexes
38 const RESULT_INDEX_ROWS = 'rows';
39 const RESULT_INDEX_STATUS = 'status';
40 const RESULT_INDEX_EXCEPTION = 'exception';
42 // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!)
43 const DB_CODE_TABLE_MISSING = 0x100;
44 const DB_CODE_TABLE_UNWRITEABLE = 0x101;
45 const DB_CODE_DATA_FILE_CORRUPT = 0x102;
48 const RESULT_OKAY = 'ok';
51 * Last thrown exception or NULL if all is fine
53 private $lastException = NULL;
56 * Protected constructor
58 * @param $className Name of the class
61 protected function __construct ($className) {
62 // Call parent constructor
63 parent::__construct($className);
67 * Getter for last exception
69 * @return $lastException Last thrown exception
71 public final function getLastException () {
72 return $this->lastException;
76 * Setter for last exception
78 * @param $lastException Last thrown exception
81 public final function setLastException (FrameworkException $exceptionInstance) {
82 $this->lastException = $exceptionInstance;
86 * Reset the last exception instance. This should be done after a "query"
87 * was completed without any errors.
91 protected final function resetLastException () {
92 $this->lastException = NULL;
96 * Removes non-public data from given array.
98 * @param $data An array with possible non-public data that needs to be removed.
99 * @return $data A cleaned up array with only public data.
101 public abstract function removeNonPublicDataFromArray (array $data);