本文整理匯總了PHP中erLhcoreClassModelUserSetting::saveThis方法的典型用法代碼示例。如果您正苦於以下問題:PHP erLhcoreClassModelUserSetting::saveThis方法的具體用法?PHP erLhcoreClassModelUserSetting::saveThis怎麽用?PHP erLhcoreClassModelUserSetting::saveThis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類erLhcoreClassModelUserSetting
的用法示例。
在下文中一共展示了erLhcoreClassModelUserSetting::saveThis方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getSetting
public static function getSetting($identifier, $default_value, $user_id = false, $noSession = false)
{
if ($user_id == false) {
$currentUser = erLhcoreClassUser::instance();
if ($currentUser->isLogged()) {
$user_id = $currentUser->getUserID();
}
}
if ($user_id !== false) {
$value = CSCacheAPC::getMem()->getSession('settings_user_id_' . $user_id . '_' . $identifier, true);
if ($value === false && ($value = CSCacheAPC::getMem()->restore('settings_user_id_' . $user_id . '_' . $identifier)) === false) {
$value = $default_value;
$list = self::getList(array('filter' => array('user_id' => $user_id, 'identifier' => $identifier)));
if (count($list) > 0) {
$item = array_shift($list);
$value = $item->value;
} else {
$item = new erLhcoreClassModelUserSetting();
$item->value = $default_value;
$item->user_id = $user_id;
$item->identifier = $identifier;
$item->saveThis();
}
CSCacheAPC::getMem()->store('settings_user_id_' . $user_id . '_' . $identifier, $value);
CSCacheAPC::getMem()->setSession('settings_user_id_' . $user_id . '_' . $identifier, $value, true);
}
} else {
$value = $default_value;
if ($noSession === false && ($value = CSCacheAPC::getMem()->getSession('anonymous_' . $identifier)) === false) {
$value = $default_value;
CSCacheAPC::getMem()->setSession('anonymous_' . $identifier, $value);
}
}
return $value;
}