public function delete($key_field, $key_value = null) { $this->datastore->beginTransaction(); $resolve = $this->queryResolve; $explicitRelations = $this->queryExplicitRelations; $this->queryResolve = false; $this->queryExplicitRelations = true; if ($key_value === null) { $data = reset($this->get(array('conditions' => $key_field))); } else { $data = reset($this->getWithField2($key_field, $key_value)); } if ($data === false) { //trigger_error("Trying to delete an item which does not exist from [{$this->package}] ", E_USER_NOTICE); } else { if (ENABLE_AUDIT_TRAILS === true && $this->disableAuditTrails === false) { SystemAuditTrailModel::log(array('item_id' => $data[$this->getKeyField()], 'item_type' => $this->package, 'description' => 'Deleted item', 'type' => SystemAuditTrailModel::AUDIT_TYPE_DELETED_DATA, 'data' => json_encode($data))); } } $this->queryResolve = $resolve; $this->queryExplicitRelations = $explicitRelations; $this->preDeleteHook($key_field, $key_value); $this->deleteImplementation($key_field, $key_value); $this->postDeleteHook(); $this->queryResolve = false; $this->queryExplicitRelations = true; $this->datastore->endTransaction(); }
public function delete($key_field, $key_value = null) { $this->datastore->beginTransaction(); $resolve = $this->queryResolve; $explicitRelations = $this->queryExplicitRelations; $this->queryResolve = false; $this->queryExplicitRelations = true; SystemAuditTrailModel::logDelete($this, $key_field, $key_value); $this->queryResolve = $resolve; $this->queryExplicitRelations = $explicitRelations; $this->preDeleteHook($key_field, $key_value); $this->deleteImplementation($key_field, $key_value); $this->postDeleteHook(); $this->queryResolve = false; $this->queryExplicitRelations = true; $this->datastore->endTransaction(); }