本文整理汇总了PHP中DatabaseFactory::rollback方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseFactory::rollback方法的具体用法?PHP DatabaseFactory::rollback怎么用?PHP DatabaseFactory::rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseFactory
的用法示例。
在下文中一共展示了DatabaseFactory::rollback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exceptionHandler
/**
* Exception handler
* @param Exception $exception The exception raised
*/
function exceptionHandler($exception)
{
try {
$exceptionMessage = NULL;
// If a transaction is in progress, rollback it
if (DatabaseFactory::isTransactionInProgress()) {
DatabaseFactory::rollback();
}
// logs exception before doing anything else, for logs to be filled even if an exception will occur during the exception treatment
$logInstance = LogTool::getInstance();
// debug exception in web context
if ($exception instanceof GenericWarningException) {
// logs warning
$logInstance->logException($exception, LogTool::WARNING_LEVEL);
} else {
// logs error
$logInstance->logException($exception);
}
$exceptionClass = get_class($exception);
if ($exception instanceof GenericException) {
// Displays message
if (TranslationTool::isTranslationAllowed()) {
$exceptionMessage = $exception->getUserLocalizedMessage();
} else {
$exceptionMessage = $exception->getMessage();
}
} else {
// If error is not managed, displays generic message
$exceptionMessage = 'GENERIC_EXCEPTION';
}
if (SystemTool::isAjaxContext()) {
echo json_encode(array('error' => $exceptionMessage), true);
} else {
echo $exceptionMessage;
}
} catch (Exception $e) {
echo $e->getMessage();
try {
LogTool::getInstance()->logException($e);
echo $exceptionClass . ' raised : ' . $exceptionMessage;
echo '+ ' . get_class($e) . ' while handling exception : ' . $e->getMessage();
exit(LogTool::KO_RETURN_CODE);
} catch (Exception $e2) {
try {
LogTool::getInstance()->logException($e2);
echo $exceptionClass . ' raised (unable to display exception details)';
exit(LogTool::KO_RETURN_CODE);
} catch (Exception $e3) {
echo 'unable to display exception details';
exit;
}
}
}
}