bd9fde97c02b3795798cbae2b89859672f29295e
[core.git] / inc / classes / main / database / class_BaseDatabaseBackend.php
1 <?php
2 /**
3  * An abstract database access class for handling database I/O requests
4  *
5  * @see                 DatabaseBackendInterface - An interface for database backends
6  * @author              Roland Haeder <webmaster@ship-simu.org>
7  * @version             0.0.0
8  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
9  * @license             GNU GPL 3.0 or any newer version
10  * @link                http://www.ship-simu.org
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 abstract class BaseDatabaseBackend extends BaseFrameworkSystem implements DatabaseBackendInterface {
26         // Constants for exceptions
27         const EXCEPTION_SQL_QUERY = 0x140;
28
29         // Result array indexes
30         const RESULT_INDEX_ROWS      = 'rows';
31         const RESULT_INDEX_STATUS    = 'status';
32         const RESULT_INDEX_EXCEPTION = 'exception';
33
34         /**
35          * Last thrown exception or NULL if all is fine
36          */
37         private $lastException = NULL;
38
39         /**
40          * Protected constructor
41          *
42          * @param       $className      Name of the class
43          * @return      void
44          */
45         protected function __construct ($className) {
46                 // Call parent constructor
47                 parent::__construct($className);
48         }
49
50         /**
51          * Getter for last exception
52          *
53          * @return      $lastException  Last thrown exception
54          */
55         public final function getLastException () {
56                 return $this->lastException;
57         }
58
59         /**
60          * Setter for last exception
61          *
62          * @param       $lastException  Last thrown exception
63          * @return      void
64          */
65         public final function setLastException (FrameworkException $exceptionInstance) {
66                 $this->lastException = $exceptionInstance;
67         }
68
69         /**
70          * Reset the last exception instance. This should be done after a "query"
71          * was completed without any errors.
72          *
73          * @return      void
74          */
75         protected final function resetLastException () {
76                 $this->lastException = NULL;
77         }
78 }
79
80 // [EOF]
81 ?>