本文整理匯總了PHP中WT_Site::setting方法的典型用法代碼示例。如果您正苦於以下問題:PHP WT_Site::setting方法的具體用法?PHP WT_Site::setting怎麽用?PHP WT_Site::setting使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WT_Site
的用法示例。
在下文中一共展示了WT_Site::setting方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getPreference
/**
* Get the site’s configuration settings
*
* @param string $setting_name
*
* @return string
*/
public static function getPreference($setting_name)
{
// There are lots of settings, and we need to fetch lots of them on every page
// so it is quicker to fetch them all in one go.
if (self::$setting === null) {
self::$setting = WT_DB::prepare("SELECT SQL_CACHE setting_name, setting_value FROM `##site_setting`")->fetchAssoc();
}
// A setting that hasn't yet been set?
if (!array_key_exists($setting_name, self::$setting)) {
self::$setting[$setting_name] = null;
}
return self::$setting[$setting_name];
}
示例2: preference
public static function preference($setting_name, $setting_value = null)
{
// There are lots of settings, and we need to fetch lots of them on every page
// so it is quicker to fetch them all in one go.
if (self::$setting === null) {
self::$setting = WT_DB::prepare("SELECT SQL_CACHE setting_name, setting_value FROM `##site_setting`")->fetchAssoc();
}
// If $setting_value is null, then GET the setting
if ($setting_value === null) {
// If parameter two is not specified, GET the setting
if (!array_key_exists($setting_name, self::$setting)) {
self::$setting[$setting_name] = null;
}
return self::$setting[$setting_name];
} else {
// If parameter two is specified, then SET the setting
if (self::preference($setting_name) != $setting_value) {
// Audit log of changes
Log::addConfigurationLog('Site setting "' . $setting_name . '" set to "' . $setting_value . '"');
}
WT_DB::prepare("REPLACE INTO `##site_setting` (setting_name, setting_value) VALUES (?, LEFT(?, 255))")->execute(array($setting_name, $setting_value));
self::$setting[$setting_name] = $setting_value;
}
}