601c042594a452e3be4789f4425f2c3c6aa54b9b
[mailer.git] / inc / classes / main / database / class_BaseDatabaseFrontend.php
1 <?php
2 /**
3  * An abstract database access class for handling database I/O requests
4  *
5  * @see DatabaseFrontendInterface       An interface for database frontends
6  *                                                              (front-end to the application)
7  */
8 abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implements DatabaseFrontendInterface, LimitableObject {
9         /**
10          * The limiter instance
11          */
12         private $limitInstance = null;
13
14         /**
15          * Private constructor
16          *
17          * @return      void
18          */
19         private function __construct($class) {
20                 // Call parent constructor
21                 parent::constructor($class);
22
23                 // Debug message
24                 if (((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) $this->getDebugInstance()->output(sprintf("[%s:] Konstruktor erreicht.<br />\n",
25                         $this->__toString()
26                 ));
27
28                 // Clean up a little
29                 $this->removeNumberFormaters();
30         }
31
32         /**
33          * The public constructor
34          *
35          * @return      void
36          */
37         public function constructor ($class) {
38                 // Calls just the private one
39                 $this->__construct($class);
40         }
41
42         /**
43          * Getter for limitation instance
44          *
45          * @return      $limitInstance          The instance to the object ObjectLimits
46          */
47         public final function getLimitInstance () {
48                 if ((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Limitierungsinstanz <strong>%s</strong> angefordert.<br />\n",
49                         $this->__toString(),
50                         $this->limitInstance->__toString()
51                 ));
52                 return $this->limitInstance;
53         }
54
55         /**
56          * Setup limitation for the saving process
57          *
58          * @param               $limitInstance  An instance of ObjectLimits which contains
59          *                                              elements we shall exclusivly include in
60          *                                              saving process
61          * @return      void
62          */
63         public final function limitObject (ObjectLimits $limitInstance) {
64                 // Debug message
65                 if ((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Limitierungsinstanz <strong>%s</strong> soll verwendet werden.<br />\n",
66                         $this->__toString(),
67                         $limitInstance->__toString()
68                 ));
69
70                 // Get limitArray for validation
71                 $array = $limitInstance->getLimitArray();
72
73                 // Sanity-check if some limitations are in the object
74                 if ($array->count() > 0) {
75                         // Okay, there is enougth
76                         $this->limitInstance = $limitInstance;
77
78                         // Debug message
79                         if ((defined('DEBUG_DATABASE')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Limitierungsinstanz <strong>%s</strong> wird verwendet und beinhaltet <strong>%s</strong> Eintr&auml;ge.<br />\n",
80                                 $this->__toString(),
81                                 $limitInstance->__toString(),
82                                 $array->count()
83                         ));
84                 }
85         }
86 }
87
88 // [EOF]
89 ?>