/** * Removes the data from the data store. * * @param Enlight_Config $config * @param array $fields * @param bool $update * @return Enlight_Config_Adapter_DbTable */ public function delete(Enlight_Config $config, $fields = null, $deleteDirty = false) { $name = $this->_namePrefix . $config->getName() . $this->_nameSuffix; $section = explode($config->getSectionSeparator(), $config->getSection()); $dbTable = $this->getTable($this->_namespaceColumn === null ? $name : null); $db = $dbTable->getAdapter(); if ($fields === null) { $fields = $config->getDirtyFields(); } if (empty($fields)) { return $this; } $where = array(); $insertData = array(); if ($this->_namespaceColumn !== null) { $insertData[$this->_namespaceColumn] = $name; $where[] = $db->quoteInto($this->_namespaceColumn . '=?', $name); } if ($section !== null) { if (is_array($this->_sectionColumn)) { foreach ($this->_sectionColumn as $key => $sectionColumn) { if (isset($section[$key])) { $where[] = $db->quoteInto($sectionColumn . '=?', $section[$key]); $insertData[$sectionColumn] = $section[$key]; } } } else { $where[] = $db->quoteInto($this->_sectionColumn . '=?', $section); $insertData[$this->_sectionColumn] = $section; } } foreach ((array) $fields as $field) { $fieldWhere = $where; $fieldWhere[] = $db->quoteInto($this->_nameColumn . '=?', $field); if (!$deleteDirty) { $fieldWhere[] = $db->quoteInto($this->_dirtyColumn . '=?', 0); } $row = $dbTable->fetchRow($fieldWhere); if ($row !== null) { $row->delete(); } } return $this; }