3 namespace CoreFramework\Database\Backend;
5 // Import framework stuff
6 use CoreFramework\Object\BaseFrameworkSystem;
9 * An abstract database access class for handling database I/O requests
11 * @see DatabaseBackend - An interface for database backends
12 * @author Roland Haeder <webmaster@shipsimu.org>
14 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
15 * @license GNU GPL 3.0 or any newer version
16 * @link http://www.shipsimu.org
18 * This program is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation, either version 3 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 abstract class BaseDatabaseBackend extends BaseFrameworkSystem implements DatabaseBackend {
32 // Constants for exceptions
33 const EXCEPTION_SQL_QUERY = 0x140;
35 // Result array indexes
36 const RESULT_INDEX_ROWS = 'rows';
37 const RESULT_INDEX_STATUS = 'status';
38 const RESULT_INDEX_EXCEPTION = 'exception';
40 // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!)
41 const DB_CODE_TABLE_MISSING = 0x100;
42 const DB_CODE_TABLE_UNWRITEABLE = 0x101;
43 const DB_CODE_DATA_FILE_CORRUPT = 0x102;
46 const RESULT_OKAY = 'ok';
49 * Last thrown exception or NULL if all is fine
51 private $lastException = NULL;
54 * Protected constructor
56 * @param $className Name of the class
59 protected function __construct ($className) {
60 // Call parent constructor
61 parent::__construct($className);
65 * Getter for last exception
67 * @return $lastException Last thrown exception
69 public final function getLastException () {
70 return $this->lastException;
74 * Setter for last exception
76 * @param $lastException Last thrown exception
79 public final function setLastException (FrameworkException $exceptionInstance) {
80 $this->lastException = $exceptionInstance;
84 * Reset the last exception instance. This should be done after a "query"
85 * was completed without any errors.
89 protected final function resetLastException () {
90 $this->lastException = NULL;
94 * Removes non-public data from given array.
96 * @param $data An array with possible non-public data that needs to be removed.
97 * @return $data A cleaned up array with only public data.
99 public abstract function removeNonPublicDataFromArray (array $data);