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 <<<<<<< HEAD:framework/main/classes/database/class_BaseDatabaseBackend.php
17 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
19 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
20 >>>>>>> Some updates::inc/main/classes/database/class_BaseDatabaseBackend.php
21 * @license GNU GPL 3.0 or any newer version
22 * @link http://www.shipsimu.org
24 * This program is free software: you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation, either version 3 of the License, or
27 * (at your option) any later version.
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
34 * You should have received a copy of the GNU General Public License
35 * along with this program. If not, see <http://www.gnu.org/licenses/>.
37 abstract class BaseDatabaseBackend extends BaseFrameworkSystem implements DatabaseBackend {
38 // Constants for exceptions
39 const EXCEPTION_SQL_QUERY = 0x140;
41 // Result array indexes
42 const RESULT_INDEX_ROWS = 'rows';
43 const RESULT_INDEX_STATUS = 'status';
44 const RESULT_INDEX_EXCEPTION = 'exception';
46 // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!)
47 const DB_CODE_TABLE_MISSING = 0x100;
48 const DB_CODE_TABLE_UNWRITEABLE = 0x101;
49 const DB_CODE_DATA_FILE_CORRUPT = 0x102;
52 const RESULT_OKAY = 'ok';
55 * Last thrown exception or NULL if all is fine
57 private $lastException = NULL;
60 * Protected constructor
62 * @param $className Name of the class
65 protected function __construct ($className) {
66 // Call parent constructor
67 parent::__construct($className);
71 * Getter for last exception
73 * @return $lastException Last thrown exception
75 public final function getLastException () {
76 return $this->lastException;
80 * Setter for last exception
82 * @param $lastException Last thrown exception
85 public final function setLastException (FrameworkException $exceptionInstance) {
86 $this->lastException = $exceptionInstance;
90 * Reset the last exception instance. This should be done after a "query"
91 * was completed without any errors.
95 protected final function resetLastException () {
96 $this->lastException = NULL;
100 * Removes non-public data from given array.
102 * @param $data An array with possible non-public data that needs to be removed.
103 * @return $data A cleaned up array with only public data.
105 public abstract function removeNonPublicDataFromArray (array $data);