Some updates:
[core.git] / framework / main / classes / database / class_BaseDatabaseBackend.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Database\Backend;
4
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;
9
10 /**
11  * An abstract database access class for handling database I/O requests
12  *
13  * @see                 DatabaseBackend - An interface for database backends
14  * @author              Roland Haeder <webmaster@shipsimu.org>
15  * @version             0.0.0
16 <<<<<<< HEAD:framework/main/classes/database/class_BaseDatabaseBackend.php
17  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
18 =======
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
23  *
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.
28  *
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.
33  *
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/>.
36  */
37 abstract class BaseDatabaseBackend extends BaseFrameworkSystem implements DatabaseBackend {
38         // Constants for exceptions
39         const EXCEPTION_SQL_QUERY = 0x140;
40
41         // Result array indexes
42         const RESULT_INDEX_ROWS      = 'rows';
43         const RESULT_INDEX_STATUS    = 'status';
44         const RESULT_INDEX_EXCEPTION = 'exception';
45
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;
50
51         // Status results
52         const RESULT_OKAY = 'ok';
53
54         /**
55          * Last thrown exception or NULL if all is fine
56          */
57         private $lastException = NULL;
58
59         /**
60          * Protected constructor
61          *
62          * @param       $className      Name of the class
63          * @return      void
64          */
65         protected function __construct ($className) {
66                 // Call parent constructor
67                 parent::__construct($className);
68         }
69
70         /**
71          * Getter for last exception
72          *
73          * @return      $lastException  Last thrown exception
74          */
75         public final function getLastException () {
76                 return $this->lastException;
77         }
78
79         /**
80          * Setter for last exception
81          *
82          * @param       $lastException  Last thrown exception
83          * @return      void
84          */
85         public final function setLastException (FrameworkException $exceptionInstance) {
86                 $this->lastException = $exceptionInstance;
87         }
88
89         /**
90          * Reset the last exception instance. This should be done after a "query"
91          * was completed without any errors.
92          *
93          * @return      void
94          */
95         protected final function resetLastException () {
96                 $this->lastException = NULL;
97         }
98
99         /**
100          * Removes non-public data from given array.
101          *
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.
104          */
105         public abstract function removeNonPublicDataFromArray (array $data);
106
107 }