本文整理匯總了PHP中DatabaseFactory::commit方法的典型用法代碼示例。如果您正苦於以下問題:PHP DatabaseFactory::commit方法的具體用法?PHP DatabaseFactory::commit怎麽用?PHP DatabaseFactory::commit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DatabaseFactory
的用法示例。
在下文中一共展示了DatabaseFactory::commit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: translate
/**
* Translates the string in correct language
* @param string $string The string to translate
* @param array $paramList The param list to be replaced in the string
* @param int $quantity The quantity to pluralize the string
* @param string $category The translation's category
* @return string The translated string
*/
public function translate($string, $paramList = NULL, $quantity = NULL, $category = NULL)
{
// Checks if string has to be pluralized
if ($quantity !== NULL && $quantity !== 1) {
$string .= '_PLURAL';
}
// Set silent mode to avoid every translation log
LogTool::getInstance()->setSilentMode();
return $string;
// Gets string from database
try {
if ($category !== NULL) {
$category = ' AND translation_category = \'' . $category . '\'';
} else {
$category = '';
}
$translation = ElementFactory::getElement('Translation', NULL, 'translation_language = \'' . $this->getLocale() . '\' AND translation_text = \'' . $string . '\'' . $category);
LogTool::getInstance()->unsetSilentMode();
if ($paramList === NULL) {
return $translation->value;
}
// String has params "%1" to be replaced
if (!is_array($paramList)) {
$paramList = array($paramList);
}
// Sets pattern to be replaced
$patternList = array();
for ($paramNumber = 1; $paramNumber <= count($paramList); ++$paramNumber) {
$patternList[] = '/%' . $paramNumber . '(?![0-9])/';
}
return preg_replace($patternList, $paramList, $translation->value);
} catch (ElementNoResultException $e) {
// String is not localized
try {
$warningTracking = new WarningTracking();
$warningTracking->addTracking("Missing " . $this->getLocale() . " translation on " . $string);
// TODO : Get template.
DatabaseFactory::commit();
} catch (Exception $e) {
}
LogTool::getInstance()->unsetSilentMode();
return 'TO_BE_LOCALIZED(' . $string . ')';
}
}
示例2:
<?php
// ends transaction
DatabaseFactory::commit();