本文整理汇总了PHP中CSearch::FormatLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP CSearch::FormatLimit方法的具体用法?PHP CSearch::FormatLimit怎么用?PHP CSearch::FormatLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSearch
的用法示例。
在下文中一共展示了CSearch::FormatLimit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetList
//.........这里部分代码省略.........
case "PARAM1":
case "PARAM2":
$arQueryWhere[] = "sc." . $key . " ='" . $DB->ForSql($value) . "'";
$bJoinSearchContent = true;
break;
case "PARAMS":
if (is_array($value)) {
foreach ($value as $p_key => $p_val) {
if (is_array($p_val)) {
foreach ($p_val as $i => $val2) {
$p_val[$i] = $DB->ForSQL($val2);
}
$p_where = " in ('" . implode("', '", $p_val) . "')";
} else {
$p_where = " = '" . $DB->ForSQL($p_val) . "'";
}
$arQueryWhere[] = "EXISTS (SELECT * FROM b_search_content_param WHERE SEARCH_CONTENT_ID = stags.SEARCH_CONTENT_ID AND PARAM_NAME = '" . $DB->ForSQL($p_key) . "' AND PARAM_VALUE " . $p_where . ")";
}
}
break;
default:
if (!is_array($arFilterEvents)) {
$arFilterEvents = GetModuleEvents("search", "OnSearchPrepareFilter", true);
}
//Try to get someone to make the filter sql
foreach ($arFilterEvents as $arEvent) {
$sql = ExecuteModuleEventEx($arEvent, array("sc.", $key, $value));
if (strlen($sql)) {
$arQueryWhere[] = "(" . $sql . ")";
$bJoinSearchContent = true;
break;
}
}
}
}
$arQueryOrder = array();
if (!is_array($arOrder)) {
$arOrder = array();
}
if (count($arOrder) < 1) {
$arOrder = array("NAME" => "ASC");
}
foreach ($arOrder as $key => $value) {
$key = strtoupper($key);
$value = strtoupper($value) == "DESC" ? "DESC" : "ASC";
switch ($key) {
case "NAME":
case "CNT":
$arQueryOrder[$key] = $key . " " . $value;
break;
case "DATE_CHANGE":
$arQueryOrder[$key] = "DC_TMP " . $value;
$arQuerySelect["DC_TMP"] = "MAX(sc.DATE_CHANGE) as DC_TMP";
$arQuerySelect["FULL_DATE_CHANGE"] = $DB->DateToCharFunction("MAX(sc.DATE_CHANGE)", "FULL") . " as FULL_DATE_CHANGE";
$arQuerySelect["DATE_CHANGE"] = $DB->DateToCharFunction("MAX(sc.DATE_CHANGE)", "SHORT") . " as DATE_CHANGE";
$bJoinSearchContent = true;
break;
}
}
if (count($arQueryOrder) < 1) {
$arQueryOrder = array("NAME" => "NAME ASC");
}
$strSql = "\n\t\t\tSELECT /*TOP*/\n\t\t\t\t" . implode("\n,", $arQuerySelect) . "\n\t\t\tFROM b_search_tags stags\n\t\t\t\t" . ($bJoinSearchContent ? "INNER JOIN b_search_content sc ON sc.ID = stags.SEARCH_CONTENT_ID" : "") . "\n\t\t\tWHERE\n\t\t\t\t" . CSearch::CheckPermissions("stags.SEARCH_CONTENT_ID") . "\n\t\t\t\t" . (count($arQueryWhere) > 0 ? "AND " . implode("\nAND ", $arQueryWhere) : "") . "\n\t\t\tGROUP BY stags.NAME\n\t\t\tORDER BY " . implode(", ", $arQueryOrder) . "\n\t\t";
if ($limit !== false) {
$limit = intVal($limit);
if ($limit <= 0 || $limit > COption::GetOptionInt("search", "max_result_size")) {
$limit = COption::GetOptionInt("search", "max_result_size");
}
if ($limit < 1) {
$limit = 100;
}
$strSql = CSearch::FormatLimit($strSql, $limit);
} else {
$strSql = str_replace("/*TOP*/", "", $strSql);
}
if (CACHED_b_search_tags !== false && $limit !== false && strlen($strTag) <= CACHED_b_search_tags_len) {
global $CACHE_MANAGER;
$path = "b_search_tags";
while (strlen($strTag) > 0) {
$path .= "/_" . ord(substr($strTag, 0, 1));
$strTag = substr($strTag, 1);
}
$cache_id = "search_tags:" . md5($strSql);
if ($CACHE_MANAGER->Read(CACHED_b_search_tags, $cache_id, $path)) {
$arTags = $CACHE_MANAGER->Get($cache_id);
} else {
$arTags = array();
$res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($ar = $res->Fetch()) {
$arTags[] = $ar;
}
$CACHE_MANAGER->Set($cache_id, $arTags);
}
$res = new CDBResult();
$res->InitFromArray($arTags);
return $res;
} else {
return $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
}