JDatabaseQuery/clear
Aus Joomla! Dokumentation
< JDatabaseQuery(Weitergeleitet von Joomla! Programmierung/Framework/JDatabaseQuery/clear)
Inhaltsverzeichnis |
[Bearbeiten] Beschreibung
Löscht das gesamte Queryobjekt oder einen bestimmten Teil von ihm zurück.
[Bearbeiten] Syntax
public function clear([$clause = null])
- @return JDatabaseQuery
- @since
| Datentyp | Parameter | Beschreibung |
|---|---|---|
| string | [$clause = null] | Der Name der zu löschenden Klausel oder leer um den gesamten Query zurückzusetzen. |
[Bearbeiten] Beispiele
[Bearbeiten] Einen bestimmten Teil des Query Objekts löschen
/* Ein Datenbankobjekt beziehen */ $db = JFactory::getDbo(); /* Ein JDatabaseQuery Objekt beziehen */ $query = $db->getQuery(true); /* Der Query wird erstellt */ $query->from('#__tabelle AS t'); $query->select('t.feldname'); $query->where('t.feld = '.$db->quote('Bedingung')); /************************* SELECT t.feldname FROM #__tabelle AS t WHERE t.feld = 'Bedingung' **************************/ /* Die WHERE-Klausel wird aus dem Query gelöscht und dann neu gesetzt. Alles andere bleibt erhalten. */ $query->clear('where'); $query->where('t.anderes_feld = '.$db->quote('Andere Bedingung')); /************************* SELECT t.feldname FROM #__tabelle AS t WHERE t.anderes_feld = 'Andere Bedingung' **************************/
Anmerkung: Wird clear() ohne Parameter aufgerufen, wird das gesamte Queryobjekt zurückgesetzt.
[Bearbeiten] Quellcode
public function clear($clause = null) { switch ($clause) { case 'select': $this->select = null; $this->type = null; break; case 'delete': $this->delete = null; $this->type = null; break; case 'update': $this->update = null; $this->type = null; break; case 'insert': $this->insert = null; $this->type = null; $this->autoIncrementField = null; break; case 'from': $this->from = null; break; case 'join': $this->join = null; break; case 'set': $this->set = null; break; case 'where': $this->where = null; break; case 'group': $this->group = null; break; case 'having': $this->having = null; break; case 'order': $this->order = null; break; case 'columns': $this->columns = null; break; case 'values': $this->values = null; break; default: $this->type = null; $this->select = null; $this->delete = null; $this->update = null; $this->insert = null; $this->from = null; $this->join = null; $this->set = null; $this->where = null; $this->group = null; $this->having = null; $this->order = null; $this->columns = null; $this->values = null; $this->autoIncrementField = null; break; } return $this; }
[Bearbeiten] Siehe auch
- JDatabaseQuery->clear auf api.joomla.org