3 * An abstract database access class for handling database I/O requests
5 * @see DatabaseFrontendInterface An interface for database frontends (front-end to the application)
6 * @author Roland Haeder <webmaster@ship-simu.org>
8 * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
9 * @license GNU GPL 3.0 or any newer version
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implements DatabaseFrontendInterface, LimitableObject {
26 * The limiter instance
28 private $limitInstance = null;
35 private function __construct($class) {
36 // Call parent constructor
37 parent::constructor($class);
40 if (((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) $this->getDebugInstance()->output(sprintf("[%s:] Konstruktor erreicht.<br />\n",
45 $this->removeNumberFormaters();
49 * The public constructor
53 public function constructor ($class) {
54 // Calls just the private one
55 $this->__construct($class);
59 * Getter for limitation instance
61 * @return $limitInstance The instance to the object ObjectLimits
63 public final function getLimitInstance () {
64 if ((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Limitierungsinstanz <strong>%s</strong> angefordert.<br />\n",
66 $this->limitInstance->__toString()
68 return $this->limitInstance;
72 * Setup limitation for the saving process
74 * @param $limitInstance An instance of ObjectLimits which contains
75 * elements we shall exclusivly include in
79 public final function limitObject (ObjectLimits $limitInstance) {
81 if ((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Limitierungsinstanz <strong>%s</strong> soll verwendet werden.<br />\n",
83 $limitInstance->__toString()
86 // Get limitArray for validation
87 $array = $limitInstance->getLimitArray();
89 // Sanity-check if some limitations are in the object
90 if ($array->count() > 0) {
91 // Okay, there is enougth
92 $this->limitInstance = $limitInstance;
95 if ((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Limitierungsinstanz <strong>%s</strong> wird verwendet und beinhaltet <strong>%s</strong> Einträge.<br />\n",
97 $limitInstance->__toString(),