3 * An abstract database access class for handling database I/O requests
5 * @see DatabaseBackendInterface - An interface for database backends
6 * @author Roland Haeder <webmaster@shipsimu.org>
8 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
9 * @license GNU GPL 3.0 or any newer version
10 * @link http://www.shipsimu.org
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.
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.
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/>.
25 abstract class BaseDatabaseBackend extends BaseFrameworkSystem implements DatabaseBackendInterface {
26 // Constants for exceptions
27 const EXCEPTION_SQL_QUERY = 0x140;
29 // Result array indexes
30 const RESULT_INDEX_ROWS = 'rows';
31 const RESULT_INDEX_STATUS = 'status';
32 const RESULT_INDEX_EXCEPTION = 'exception';
34 // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!)
35 const DB_CODE_TABLE_MISSING = 0x100;
36 const DB_CODE_TABLE_UNWRITEABLE = 0x101;
37 const DB_CODE_DATA_FILE_CORRUPT = 0x102;
40 const RESULT_OKAY = 'ok';
43 * Last thrown exception or NULL if all is fine
45 private $lastException = NULL;
48 * Protected constructor
50 * @param $className Name of the class
53 protected function __construct ($className) {
54 // Call parent constructor
55 parent::__construct($className);
59 * Getter for last exception
61 * @return $lastException Last thrown exception
63 public final function getLastException () {
64 return $this->lastException;
68 * Setter for last exception
70 * @param $lastException Last thrown exception
73 public final function setLastException (FrameworkException $exceptionInstance) {
74 $this->lastException = $exceptionInstance;
78 * Reset the last exception instance. This should be done after a "query"
79 * was completed without any errors.
83 protected final function resetLastException () {
84 $this->lastException = NULL;