public function deactivate(EventCustomFieldDefinitionModel $model, UserAccountModel $userAccountModel = null) { global $DB; try { $DB->beginTransaction(); $stat = $DB->prepare("UPDATE event_custom_field_definition_information SET is_active='0' WHERE id=:id"); $stat->execute(array('id' => $model->getId())); $stat = $DB->prepare("INSERT INTO event_custom_field_definition_history (event_custom_field_definition_id, key_changed, extension_id_changed,type_changed,label_changed,is_active,created_at,user_account_id) " . "VALUES (:event_custom_field_definition_id, -2, -2,-2,-2,'0',:created_at,:user_account_id)"); $stat->execute(array('event_custom_field_definition_id' => $model->getId(), 'created_at' => \TimeSource::getFormattedForDataBase(), 'user_account_id' => $userAccountModel ? $userAccountModel->getId() : null)); $DB->commit(); } catch (Exception $e) { $DB->rollBack(); } $this->updateSiteCache($model->getSiteId()); }