本文整理汇总了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();