
Öffentliche Methoden | |
| __construct (array $data=array(), $readOnly=false, $synchronous=false) | |
| Konstruktor. | |
| __sleep () | |
| Serialisierungsroutine. | |
| delete () | |
| Zum Objekt gehörende Datensätze aus der Datenbank löschen. | |
| exists () | |
| Prüft, ob zum Objekt gehörende Datensätze in der Datenbank existieren, ohne diese (vollständig) zu laden. | |
| getData ($properties=null, $default=null, $reload=false) | |
| Gibt Daten zurück und lädt sie vorher ggf. | |
| getTable ($name=null) | |
| Gibt Tabellenobjekt zurück. | |
| hasIdentifier ($throw=false) | |
| Prüft, ob für das Laden aus der Datenbank benötigte Identifizierer vorhanden sind. | |
| insert () | |
| Fügt Daten des Objekts in Datenbank ein. | |
| isSynchronous ($refresh=false) | |
| Gibt Synchronität zurück. | |
| refresh () | |
| Aktualisiert Daten des Objekts aus der Datenbank und überschreibt eventuelle Änderungen an den Daten. | |
| setSynchronous ($synchronous=true) | |
| Manuelles Setzen der Synchronität. | |
| update (array $properties=array()) | |
| Aktualisiert (teilweise) Daten des Objekts in der Datenbank. | |
Geschützte Methoden | |
| _addWhere (Zend_Db_Select $select, array $identifiers=array(), array $options=array()) | |
| Fügt einem Select-Statement ein Where-Klausel hinzu. | |
| _checkValidity () | |
| Prüft Gültigkeit, indemie Identifizierer kontrolliert werden. | |
| _getValidIdentifiers ($firstOnly=true) | |
| Gibt (alle) Identifizierer zurück, für die im Moment Daten existieren. | |
| _parseResult ($row, $setSynchronous=true) | |
| Parst das Ergebnis einer Datenbankabfrage (nur je eine Zeile) und markiert das Objekt ggf. | |
| _resetValidity () | |
| Setzt Gültigkeit zurück. | |
Geschützte Attribute | |
| $_identifiers = array() | |
| Array mit Eigenschaften, die eine klare Identifizierung eines Datenbanksatzes zulassen. | |
| $_synchronous = null | |
| Ob Daten des Objekt zu Daten in Datenbank synchron sind. | |
| $_table = null | |
| string, zunächst Name und später Objekt der (Haupt-)-Tabelle | |
Definiert in Zeile 9 der Datei Abstract.php.
| Dsao_Db_Table_DataHandler_Abstract::__construct | ( | array $ | data = array(), |
|
| $ | readOnly = false, |
|||
| $ | synchronous = false | |||
| ) |
Konstruktor.
Erlaubt, Gültigkeit zu setzen.
| $data | array, Daten | |
| $readOnly | bool, schreibgeschützt | |
| $synchronous | bool, ob übergeben Daten gültig sind (kein DB-Check) |
Definiert in Zeile 43 der Datei Abstract.php.
Benutzt setSynchronous().
00044 { 00045 parent::__construct($data, $readOnly); 00046 00047 $this->setSynchronous($synchronous); 00048 }
| Dsao_Db_Table_DataHandler_Abstract::__sleep | ( | ) |
Serialisierungsroutine.
Speichert Synchronität.
Erneute Implementation von Dsao_DataHandler_Abstract.
Definiert in Zeile 57 der Datei Abstract.php.
| Dsao_Db_Table_DataHandler_Abstract::_addWhere | ( | Zend_Db_Select $ | select, | |
| array $ | identifiers = array(), |
|||
| array $ | options = array() | |||
| ) | [protected] |
Fügt einem Select-Statement ein Where-Klausel hinzu.
Alle Elemente (entweder als dritter Parameter übergeben oder aus Methode _getValidIdentifiers() geladen) werden mit 'and' oder 'or' zusammengefügt.
Optionen:
operator: Zend_Db_Select::SQL_OR bzw. *SQL_AND table: Tabellenpräfix für komplexere Statements values: Array mit Werten, die Daten in $_data überschreiben
| $select | Zend_Db_Select, Select-Objekt | |
| $identifiers | array, Identifizierer | |
| $options | array, Optionen |
Definiert in Zeile 79 der Datei Abstract.php.
Benutzt Dsao_DataHandler_Abstract::__get(), _getValidIdentifiers() und getTable().
Wird benutzt von Dsao_User::_fetchAll(), Dsao_Hero::exists() und Dsao_User::exists().
00080 { 00081 // Optionen 00082 $table = (isset($options['table']) ? $options['table'].'.' : ''); 00083 $values = (isset($options['values']) ? (array) $options['values'] : array()); 00084 00085 // Falls keine Identifizierer übergeben wurden, die ersten gültigen nehmen 00086 if (!$identifiers) 00087 { 00088 $identifiers = $this->_getValidIdentifiers(); 00089 } 00090 00091 // Methode zum Hinzufügen der Where-Klausel ermitteln 00092 $whereMethod = 'where'; 00093 00094 // Falls Operator übergeben wurde 00095 if (isset($options['operator']) && $operator == Zend_Db_Select::SQL_OR) 00096 { 00097 $whereMethod = 'orWhere'; 00098 } 00099 00100 // Identifizierer durchgehen 00101 foreach ($identifiers as $identifier) 00102 { 00103 // Identifizierer quoten 00104 $identifierQuoted = $this->getTable()->getAdapter() 00105 ->quoteIdentifier($table.$identifier); 00106 00107 // Wert bestimmen 00108 $value = (isset($values[$identifier]) ? $values[$identifier] : 00109 $this->__get($identifier)); 00110 00111 // Where-Klausel hinzufügen 00112 $select->$whereMethod($identifierQuoted.' = ?', $value); 00113 } 00114 }
| Dsao_Db_Table_DataHandler_Abstract::_checkValidity | ( | ) | [protected] |
Prüft Gültigkeit, indemie Identifizierer kontrolliert werden.
Erneute Implementation von Dsao_DataHandler_Abstract.
Erneute Implementation in Dsao_Hero, Dsao_Scroll und Dsao_User.
Definiert in Zeile 121 der Datei Abstract.php.
Benutzt hasIdentifier() und isSynchronous().
00122 { 00123 // Falls die Elternklasse das Objekt als gültig markiert hat und entweder 00124 // Identifizierer vorhanden oder Objekt noch synchron 00125 if (parent::_checkValidity() && 00126 ($this->hasIdentifier() || $this->isSynchronous())) 00127 { 00128 $this->_valid = true; 00129 } 00130 00131 return $this->_valid; 00132 }
| Dsao_Db_Table_DataHandler_Abstract::_getValidIdentifiers | ( | $ | firstOnly = true |
) | [protected] |
Gibt (alle) Identifizierer zurück, für die im Moment Daten existieren.
| $firstOnly | bool, ob nach dem ersten gültigen abgebrochen werden soll |
Definiert in Zeile 141 der Datei Abstract.php.
Benutzt Dsao_DataHandler_Abstract::__isset().
Wird benutzt von _addWhere(), Dsao_Db_Table_DataHandler_Row_Abstract::_fetchMinimal() und hasIdentifier().
00142 { 00143 $identifiersValid = array(); 00144 00145 // Identifizierer durchgehen 00146 foreach ($this->_identifiers as $index => $identifiers) 00147 { 00148 $identifiers = (array) $identifiers; 00149 00150 foreach ($identifiers as $identifier) 00151 { 00152 // Falls einer der Identifizierer nicht existiert, direkt in den 00153 // nächsten Durchlauf der darüber liegenden Schleife springen 00154 if (!$this->__isset($identifier)) 00155 { 00156 break 2; 00157 } 00158 } 00159 00160 $identifiersValid[] = $identifiers; 00161 00162 // Falls nach erstem Fund abgebrochen werden soll 00163 if (true === $firstOnly) 00164 { 00165 return array_pop($identifiersValid); 00166 } 00167 } 00168 00169 return $identifiersValid; 00170 }
| Dsao_Db_Table_DataHandler_Abstract::_parseResult | ( | $ | row, | |
| $ | setSynchronous = true | |||
| ) | [protected] |
Parst das Ergebnis einer Datenbankabfrage (nur je eine Zeile) und markiert das Objekt ggf.
als synchron.
| $row | array|null|Zend_Db_Tabe_Row_Abstract, Tabellenzeile, Array oder null | |
| $synchronous | bool, ob Objet als (un)synchron markiert werden soll |
Definiert in Zeile 181 der Datei Abstract.php.
Benutzt Dsao_DataHandler_Abstract::setData().
Wird benutzt von Dsao_User::_fetchAll(), Dsao_Hero::exists() und Dsao_Scroll::refresh().
00182 { 00183 $synchronous = false; 00184 00185 // Falls Zeile gefunden wurde 00186 if ($row) 00187 { 00188 $synchronous = true; 00189 00190 // Falls kein Array übergeben wurde, umwandeln 00191 if (!is_array($row)) 00192 { 00193 $row = $row->toArray(); 00194 } 00195 00196 // Daten setzen 00197 $this->setData($row); 00198 } 00199 00200 // Falls Synchronität gesetzt werden soll 00201 if ($setSynchronous) 00202 { 00203 $this->_synchronous = $synchronous; 00204 $this->_valid = true; 00205 } 00206 00207 return $synchronous; 00208 }
| Dsao_Db_Table_DataHandler_Abstract::_resetValidity | ( | ) | [protected] |
Setzt Gültigkeit zurück.
Erneute Implementation von Dsao_DataHandler_Abstract.
Definiert in Zeile 215 der Datei Abstract.php.
Benutzt setSynchronous().
00216 { 00217 parent::_resetValidity(); 00218 00219 // Falls Objekt synchron 00220 if (true === $this->_synchronous) 00221 { 00222 $this->setSynchronous(false); 00223 } 00224 }
| Dsao_Db_Table_DataHandler_Abstract::delete | ( | ) |
Zum Objekt gehörende Datensätze aus der Datenbank löschen.
Erneute Implementation in Dsao_Db_Table_DataHandler_Row_Abstract.
Definiert in Zeile 231 der Datei Abstract.php.
Benutzt hasIdentifier() und Dsao_DataHandler_Abstract::isReadOnly().
Wird benutzt von Dsao_Scroll::delete().
00232 { 00233 // Ggf. Exception werfen 00234 $this->isReadOnly(true); 00235 $this->hasIdentifier(true); 00236 00237 // Synchronität zurücksetzen 00238 $this->_synchronous = null; 00239 00240 return $this; 00241 }
| Dsao_Db_Table_DataHandler_Abstract::exists | ( | ) |
Prüft, ob zum Objekt gehörende Datensätze in der Datenbank existieren, ohne diese (vollständig) zu laden.
Erneute Implementation in Dsao_Db_Table_DataHandler_Row_Abstract, Dsao_Hero und Dsao_User.
Definiert in Zeile 249 der Datei Abstract.php.
Benutzt hasIdentifier() und isSynchronous().
00250 { 00251 // Falls Objekt noch synchron 00252 if ($this->isSynchronous()) 00253 { 00254 return true; 00255 } 00256 // Falls keine Identifizierer vorhanden 00257 else if (!$this->hasIdentifier()) 00258 { 00259 return false; 00260 } 00261 00262 return null; 00263 }
| Dsao_Db_Table_DataHandler_Abstract::getData | ( | $ | properties = null, |
|
| $ | default = null, |
|||
| $ | reload = false | |||
| ) |
Gibt Daten zurück und lädt sie vorher ggf.
neu.
| $properties | array, Array mit Namen der Eigenschaften | |
| $default | mixed Standardwert | |
| $reload | bool, ob Daten neu geladen werden sollen |
Definiert in Zeile 273 der Datei Abstract.php.
Benutzt refresh().
Wird benutzt von Dsao_Hero::update(), Dsao_User::update() und Dsao_Db_Table_DataHandler_Row_Abstract::update().
00274 { 00275 // Falls Daten erneut geladen werden sollen 00276 if ($reload) 00277 { 00278 // Daten erneut aus Datenbank laden 00279 $this->refresh(); 00280 } 00281 00282 return parent::getData($properties, $default); 00283 }
| Dsao_Db_Table_DataHandler_Abstract::getTable | ( | $ | name = null |
) |
Gibt Tabellenobjekt zurück.
| $name | string, Tabellenname |
Definiert in Zeile 292 der Datei Abstract.php.
Wird benutzt von _addWhere(), Dsao_Scroll::_delete(), Dsao_User::_fetchAll(), Dsao_Db_Table_DataHandler_Row_Abstract::_fetchMinimal(), Dsao_Scroll::delete(), Dsao_Hero::exists(), Dsao_User::exists(), Dsao_Scroll::insert(), Dsao_Db_Table_DataHandler_Row_Abstract::insert(), Dsao_Scroll::markRead(), Dsao_Scroll::refresh(), Dsao_Db_Table_DataHandler_Row_Abstract::setRow(), Dsao_Hero::update() und Dsao_User::update().
00293 { 00294 // Falls kein Tabellenname übergeben wurde 00295 if (null == $name) 00296 { 00297 // Falls Tabelle noch nicht instanziiert wurde 00298 if (is_string($this->_table)) 00299 { 00300 $this->_table = Dsao_Registry::getTable($this->_table); 00301 } 00302 00303 return $this->_table; 00304 } 00305 // Ansonsten Tabelle mit übergebenem Namen zurück geben 00306 else 00307 { 00308 return Dsao_Registry::getTable($name); 00309 } 00310 }
| Dsao_Db_Table_DataHandler_Abstract::hasIdentifier | ( | $ | throw = false |
) |
Prüft, ob für das Laden aus der Datenbank benötigte Identifizierer vorhanden sind.
| $throw | bool, ob Exception geworfen werden darf |
Definiert in Zeile 319 der Datei Abstract.php.
Benutzt _getValidIdentifiers() und isSynchronous().
Wird benutzt von _checkValidity(), delete(), exists() und refresh().
00320 { 00321 // Falls gültige Identifizierer vorhanden oder Objekt synchron 00322 if ($this->isSynchronous() || $this->_getValidIdentifiers()) 00323 { 00324 return true; 00325 } 00326 // Ansonsten ggf. Exception werfen 00327 else if ($throw) 00328 { 00329 throw new Dsao_Exception 00330 ('dsao_db_table_datahandler_abstract_identifier'); 00331 } 00332 00333 return false; 00334 }
| Dsao_Db_Table_DataHandler_Abstract::insert | ( | ) |
Fügt Daten des Objekts in Datenbank ein.
Erneute Implementation in Dsao_Db_Table_DataHandler_Row_Abstract, Dsao_Hero, Dsao_Scroll und Dsao_User.
Definiert in Zeile 341 der Datei Abstract.php.
Benutzt Dsao_DataHandler_Abstract::isReadOnly(), isSynchronous() und Dsao_DataHandler_Abstract::isValid().
00342 { 00343 $this->isReadOnly(true); 00344 00345 // Falls keine Änderungen vorgenommen wurden 00346 if (true === $this->isSynchronous()) 00347 { 00348 return $this; 00349 } 00350 // Falls Objekt bereits in Datenbank 00351 else if (false === $this->isSynchronous()) 00352 { 00353 throw new Dsao_Exception 00354 ('dsao_db_table_datahandler_abstract_insert_synchronous'); 00355 } 00356 00357 // Falls Objekt nicht gültig, abbrechen 00358 $this->isValid(true); 00359 00360 return $this; 00361 }
| Dsao_Db_Table_DataHandler_Abstract::isSynchronous | ( | $ | refresh = false |
) |
Gibt Synchronität zurück.
| $refresh | bool, ob synchronisiert werden soll, wenn Objektdaten nicht mehr synchron |
Definiert in Zeile 370 der Datei Abstract.php.
Benutzt refresh().
Wird benutzt von _checkValidity(), Dsao_Db_Table_DataHandler_Row_Abstract::delete(), exists(), Dsao_Db_Table_DataHandler_Row_Abstract::getRow(), hasIdentifier(), insert(), Dsao_Scroll::markRead(), Dsao_Db_Table_DataHandler_Row_Abstract::refresh() und update().
00371 { 00372 if (false === $this->_synchronous && $refresh) 00373 { 00374 $this->refresh(); 00375 } 00376 00377 return $this->_synchronous; 00378 }
| Dsao_Db_Table_DataHandler_Abstract::refresh | ( | ) |
Aktualisiert Daten des Objekts aus der Datenbank und überschreibt eventuelle Änderungen an den Daten.
Erneute Implementation in Dsao_Hero und Dsao_User.
Definiert in Zeile 386 der Datei Abstract.php.
Benutzt hasIdentifier() und Dsao_DataHandler_Abstract::isReadOnly().
Wird benutzt von getData(), isSynchronous(), Dsao_Scroll::refresh() und Dsao_Db_Table_DataHandler_Row_Abstract::refresh().
00387 { 00388 // Ggf. Exception werfen 00389 $this->isReadOnly(true); 00390 $this->hasIdentifier(true); 00391 00392 return $this; 00393 }
| Dsao_Db_Table_DataHandler_Abstract::setSynchronous | ( | $ | synchronous = true |
) |
Manuelles Setzen der Synchronität.
| $synchronous | bool, synchron? |
Definiert in Zeile 401 der Datei Abstract.php.
Wird benutzt von __construct(), _resetValidity(), Dsao_Scroll::insert(), Dsao_Hero::update() und Dsao_User::update().
00402 { 00403 $this->_synchronous = (bool) $synchronous; 00404 00405 // Wenn Objekt synchron ist, muss es auch gültig sein 00406 if ($synchronous) 00407 { 00408 $this->_valid = true; 00409 } 00410 00411 return $this; 00412 }
| Dsao_Db_Table_DataHandler_Abstract::update | ( | array $ | properties = array() |
) |
Aktualisiert (teilweise) Daten des Objekts in der Datenbank.
| $properties | array, Felder, die geändert werden sollen |
Erneute Implementation in Dsao_Db_Table_DataHandler_Row_Abstract, Dsao_Hero und Dsao_User.
Definiert in Zeile 420 der Datei Abstract.php.
Benutzt Dsao_DataHandler_Abstract::isReadOnly() und isSynchronous().
00421 { 00422 $this->isReadOnly(true); 00423 00424 // Falls noch nie synchron gewesen, also nicht mit Datenbank verbunden 00425 if (null === $this->isSynchronous()) 00426 { 00427 throw new Dsao_Exception 00428 ('dsao_db_table_datahandler_abstract_update_not_connected'); 00429 } 00430 00431 return $this; 00432 }
Dsao_Db_Table_DataHandler_Abstract::$_identifiers = array() [protected] |
Array mit Eigenschaften, die eine klare Identifizierung eines Datenbanksatzes zulassen.
Der Primary-Key muss hier nicht festgehalten werden, nur weitere Unique-Spalten oder Kombinationen. Über Unterarrays können Spaltenkombinationen festgehalten werden.
Erneute Implementation in Dsao_Scroll und Dsao_User.
Definiert in Zeile 18 der Datei Abstract.php.
Dsao_Db_Table_DataHandler_Abstract::$_synchronous = null [protected] |
Ob Daten des Objekt zu Daten in Datenbank synchron sind.
null = Daten des Objekts haben (noch) keinen Bezug zu Datenbankdaten; false = Daten sind nicht mehr synchron true = Daten sind sychron
Definiert in Zeile 26 der Datei Abstract.php.
1.5.7.1