当前位置: 首页>>代码示例>>PHP>>正文


PHP CCatalog::GetFilterOperation方法代码示例

本文整理汇总了PHP中CCatalog::GetFilterOperation方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalog::GetFilterOperation方法的具体用法?PHP CCatalog::GetFilterOperation怎么用?PHP CCatalog::GetFilterOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCatalog的用法示例。


在下文中一共展示了CCatalog::GetFilterOperation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PrepareSql


//.........这里部分代码省略.........
                     if (isset($arFields[$val]["FROM"]) && strlen($arFields[$val]["FROM"]) > 0 && !in_array($arFields[$val]["FROM"], $arAlreadyJoined)) {
                         if (strlen($strSqlFrom) > 0) {
                             $strSqlFrom .= " ";
                         }
                         $strSqlFrom .= $arFields[$val]["FROM"];
                         $arAlreadyJoined[] = $arFields[$val]["FROM"];
                     }
                 }
             }
         }
         if (strlen($strSqlGroupBy) > 0) {
             if (strlen($strSqlSelect) > 0) {
                 $strSqlSelect .= ", ";
             }
             $strSqlSelect .= "COUNT(%%_DISTINCT_%% " . $arFields[$arFieldsKeys[0]]["FIELD"] . ") as CNT";
         } else {
             $strSqlSelect = "%%_DISTINCT_%% " . $strSqlSelect;
         }
     }
     // <-- SELECT
     // WHERE -->
     $arSqlSearch = array();
     if (!is_array($arFilter)) {
         $filter_keys = array();
     } else {
         $filter_keys = array_keys($arFilter);
     }
     for ($i = 0; $i < count($filter_keys); $i++) {
         $vals = $arFilter[$filter_keys[$i]];
         if (!is_array($vals)) {
             $vals = array($vals);
         }
         $key = $filter_keys[$i];
         $key_res = CCatalog::GetFilterOperation($key);
         $key = $key_res["FIELD"];
         $strNegative = $key_res["NEGATIVE"];
         $strOperation = $key_res["OPERATION"];
         $strOrNull = $key_res["OR_NULL"];
         if (array_key_exists($key, $arFields)) {
             $arSqlSearch_tmp = array();
             if (count($vals) > 0) {
                 if ($strOperation == "IN") {
                     if (isset($arFields[$key]["WHERE"])) {
                         $arSqlSearch_tmp1 = call_user_func_array($arFields[$key]["WHERE"], array($vals, $key, $strOperation, $strNegative, $arFields[$key]["FIELD"], &$arFields, &$arFilter));
                         if ($arSqlSearch_tmp1 !== false) {
                             $arSqlSearch_tmp[] = $arSqlSearch_tmp1;
                         }
                     } else {
                         if ($arFields[$key]["TYPE"] == "int") {
                             array_walk($vals, create_function("&\$item", "\$item=IntVal(\$item);"));
                             $vals = array_unique($vals);
                             $val = implode(",", $vals);
                             if (count($vals) <= 0) {
                                 $arSqlSearch_tmp[] = "(1 = 2)";
                             } else {
                                 $arSqlSearch_tmp[] = ($strNegative == "Y" ? " NOT " : "") . "(" . $arFields[$key]["FIELD"] . " IN (" . $val . "))";
                             }
                         } elseif ($arFields[$key]["TYPE"] == "double") {
                             array_walk($vals, create_function("&\$item", "\$item=DoubleVal(\$item);"));
                             $vals = array_unique($vals);
                             $val = implode(",", $vals);
                             if (count($vals) <= 0) {
                                 $arSqlSearch_tmp[] = "(1 = 2)";
                             } else {
                                 $arSqlSearch_tmp[] = ($strNegative == "Y" ? " NOT " : "") . "(" . $arFields[$key]["FIELD"] . " " . $strOperation . " (" . $val . "))";
                             }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:67,代码来源:sharepoint.php

示例2: _PrepareSql


//.........这里部分代码省略.........
                             $strSqlSelect .= $DB->DateToCharFunction($arFields[$val]["FIELD"], "SHORT") . " as " . $val;
                         } else {
                             $strSqlSelect .= $arFields[$val]["FIELD"] . " as " . $val;
                         }
                     }
                     if (isset($arFields[$val]["FROM"]) && strlen($arFields[$val]["FROM"]) > 0 && !in_array($arFields[$val]["FROM"], $arAlreadyJoined)) {
                         if ('' != $strSqlFrom) {
                             $strSqlFrom .= " ";
                         }
                         $strSqlFrom .= $arFields[$val]["FROM"];
                         $arAlreadyJoined[] = $arFields[$val]["FROM"];
                     }
                 }
             }
         }
         if ('' != $strSqlGroupBy) {
             if ('' != $strSqlSelect) {
                 $strSqlSelect .= ", ";
             }
             $strSqlSelect .= "COUNT(%%_DISTINCT_%% " . $arFields[$arFieldsKeys[0]]["FIELD"] . ") as CNT";
         } else {
             $strSqlSelect = "%%_DISTINCT_%% " . $strSqlSelect;
         }
     }
     // <-- SELECT
     // WHERE -->
     $arSqlSearch = array();
     $arSqlHaving = array();
     $filter_keys = !is_array($arFilter) ? array() : array_keys($arFilter);
     for ($i = 0, $intCount = count($filter_keys); $i < $intCount; $i++) {
         $vals = $arFilter[$filter_keys[$i]];
         $vals = !is_array($vals) ? array($vals) : array_values($vals);
         $key = $filter_keys[$i];
         $key_res = CCatalog::GetFilterOperation($key);
         if (empty($key_res)) {
             continue;
         }
         $key = $key_res["FIELD"];
         $strNegative = $key_res["NEGATIVE"];
         $strOperation = $key_res["OPERATION"];
         $strOrNull = $key_res["OR_NULL"];
         if ('' != $key && isset($arFields[$key])) {
             $arSqlSearch_tmp = array();
             $arSqlHaving_tmp = array();
             for ($j = 0, $intCountVals = count($vals); $j < $intCountVals; $j++) {
                 $val = $vals[$j];
                 if (isset($arFields[$key]["WHERE"])) {
                     $arSqlSearch_tmp1 = call_user_func_array($arFields[$key]["WHERE"], array($val, $key, $strOperation, $strNegative, $arFields[$key]["FIELD"], &$arFields, &$arFilter));
                     if ($arSqlSearch_tmp1 !== false) {
                         if (isset($arFields[$key]["GROUPED"]) && $arFields[$key]["GROUPED"] == "Y") {
                             $arSqlHaving_tmp[] = $arSqlSearch_tmp1;
                         } else {
                             $arSqlSearch_tmp[] = $arSqlSearch_tmp1;
                         }
                     }
                 } else {
                     $arSqlSearch_tmp1 = "";
                     if ($arFields[$key]["TYPE"] == "int") {
                         if ((int) $val == 0 && strpos($strOperation, "=") !== false) {
                             $arSqlSearch_tmp1 = "(" . $arFields[$key]["FIELD"] . " IS " . ($strNegative == "Y" ? "NOT " : "") . "NULL) " . ($strNegative == "Y" ? "AND" : "OR") . " " . ($strNegative == "Y" ? "NOT " : "") . "(" . $arFields[$key]["FIELD"] . " " . $strOperation . " 0)";
                         } else {
                             $arSqlSearch_tmp1 = ($strNegative == "Y" ? " " . $arFields[$key]["FIELD"] . " IS NULL OR NOT " : "") . "(" . $arFields[$key]["FIELD"] . " " . $strOperation . " " . (int) $val . " )";
                         }
                     } elseif ($arFields[$key]["TYPE"] == "double") {
                         $val = str_replace(",", ".", $val);
                         if (DoubleVal($val) == 0 && strpos($strOperation, "=") !== false) {
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:67,代码来源:catalog.php


注:本文中的CCatalog::GetFilterOperation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。