/** * Удаление текущей записи из БД */ public function remove() { /** * Перед удалением объекта выполним валидаторы onDelete для модели */ $valid = $this->validateModel(VALIDATION_EVENT_REMOVE); if (!$valid) { $controller = CSession::getCurrentController(); if (!is_null($controller)) { $url = WEB_ROOT; if (array_key_exists("HTTP_REFERER", $_SERVER)) { $url = $_SERVER["HTTP_REFERER"]; } $controller->redirect($url, $this->getValidationErrors()); } } $transaction = new CTransaction(); try { $this->getRecord()->remove(); } catch (Exception $e) { $transaction->rollback(); throw new Exception($e); } $transaction->commit(); }
public static function getTextStringInCorrectEncoding($text) { if (is_null(CSession::getCurrentController())) { return mb_convert_encoding($text, "Windows-1251"); } else { return $text; } }