function GetCount($Params) { global $DB, $USER, $CACHE_MANAGER; $userId = $USER->GetId(); $cacheId = 'stickers_count_' . $userId . "_" . $Params["PAGE_URL"]; $bCache = CACHED_stickers_count !== false; if ($bCache && $CACHE_MANAGER->Read(CACHED_stickers_count, $cacheId, "fileman_stickers_count")) { return $CACHE_MANAGER->Get($cacheId); } $strSqlSearch = "((ST.PERSONAL='Y' AND ST.CREATED_BY=" . intVal($userId) . ") OR ST.PERSONAL='N')"; $strSqlSearch .= "\n AND ST.CLOSED='N' AND ST.DELETED='N' AND ST.SITE_ID='" . $DB->ForSql($Params['SITE_ID']) . "'"; if ($Params["PAGE_URL"]) { $strSqlSearch .= "\n AND ST.PAGE_URL='" . $DB->ForSql($Params["PAGE_URL"]) . "'"; } $strSql = "\n\t\t\tSELECT\n\t\t\t\tCOUNT(ST.ID) as CNT\n\t\t\tFROM\n\t\t\t\tb_sticker ST\n\t\t\tWHERE\n\t\t\t\t{$strSqlSearch}"; $err_mess = CSticker::GetErrorMess() . "<br>Function: GetCount<br>Line: "; $res = $DB->Query($strSql, false, $err_mess . __LINE__); $count = 0; if ($arRes = $res->Fetch()) { $count = $arRes['CNT']; } if ($bCache) { $CACHE_MANAGER->Set($cacheId, $count); } return $count; }
function GetCount($Params) { global $DB, $USER; $userId = $USER->GetId(); $strSqlSearch = "((ST.PERSONAL='Y' AND ST.CREATED_BY=".intVal($userId).") OR ST.PERSONAL='N')"; $strSqlSearch .= "\n AND ST.CLOSED='N' AND ST.DELETED='N' AND ST.SITE_ID='".$DB->ForSql($Params['SITE_ID'])."'"; if ($Params["PAGE_URL"]) $strSqlSearch .= "\n AND ST.PAGE_URL='".$DB->ForSql($Params["PAGE_URL"])."'"; $strSql = " SELECT COUNT(ST.ID) as CNT FROM b_sticker ST WHERE $strSqlSearch"; $err_mess = (CSticker::GetErrorMess())."<br>Function: GetCount<br>Line: "; $res = $DB->Query($strSql, false, $err_mess.__LINE__); $count = 0; if($arRes = $res->Fetch()) $count = $arRes['CNT']; return $count; }