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


PHP CIBlockElement::MkFilter方法代码示例

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


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

示例1: GetListEx

	public static function GetListEx($arOrder=array("SORT"=>"ASC"), $arFilter=array())
	{
		return false;
		global $DB, $USER;

		$arSqlSearch = CIBlockElement::MkFilter($arFilter);
		$bSections = false;
		if($arSqlSearch["SECTION"]=="Y")
		{
			$bSections = true;
			unset($arSqlSearch["SECTION"]);
		}
		$strSqlSearch = "";
		for ($i = 0, $intCount = count($arSqlSearch); $i < $intCount; $i++)
			$strSqlSearch .= " AND (".$arSqlSearch[$i].") ";

		$MAX_LOCK = intval(COption::GetOptionString("workflow", "MAX_LOCK_TIME", "60"));
		$uid = intval($USER->GetID());

		$db_groups = CCatalogGroup::GetList(array("SORT" => "ASC"));
		$strSelectPart = "";
		$strFromPart = "";
		$i = -1;
		while ($groups = $db_groups->Fetch())
		{
			$i++;
			$strSelectPart .= ", P".$i.".PRICE as PRICE".$i.", P".$i.".CURRENCY as CURRENCY".$i.", P".$i.".CATALOG_GROUP_ID as CATALOG_GROUP_ID".$i.", P".$i.".ID as PRICE_ID".$i." ";
			$strFromPart .= " LEFT JOIN b_catalog_price P".$i." ON (P".$i.".PRODUCT_ID = BE.ID AND P".$i.".CATALOG_GROUP_ID = ".$groups["ID"].") ";
		}
		$maxInd = $i;

		if (!$USER->IsAdmin())
		{
			$strSql =
				"SELECT DISTINCT BE.*, ".
				"	".$DB->DateToCharFunction("BE.TIMESTAMP_X")." as TIMESTAMP_X, ".
				"	".$DB->DateToCharFunction("BE.ACTIVE_FROM", "SHORT")." as ACTIVE_FROM, ".
				"	".$DB->DateToCharFunction("BE.ACTIVE_TO", "SHORT")." as ACTIVE_TO, ".
				"	".$DB->DateToCharFunction("BE.WF_DATE_LOCK")." as WF_DATE_LOCK, ".
				"	L.DIR as LANG_DIR, B.DETAIL_PAGE_URL, B.LIST_PAGE_URL, ".
				"	CAP.QUANTITY, CAP.QUANTITY_RESERVED, IF (CAP.QUANTITY_TRACE = 'D', '".$DB->ForSql(COption::GetOptionString('catalog','default_quantity_trace','N'))."', CAP.QUANTITY_TRACE) as QUANTITY_TRACE, CAP.WEIGHT, ".
				"   IF (CAP.CAN_BUY_ZERO = 'D', '".$DB->ForSql(COption::GetOptionString('catalog','default_can_buy_zero','N'))."', CAP.CAN_BUY_ZERO) as CAN_BUY_ZERO, ".
				"   IF (CAP.NEGATIVE_AMOUNT_TRACE = 'D', '".$DB->ForSql(COption::GetOptionString('catalog','allow_negative_amount','N'))."', CAP.NEGATIVE_AMOUNT_TRACE) as NEGATIVE_AMOUNT_TRACE, ".
				"	CAP.VAT_ID, CAP.VAT_INCLUDED, ".
				"	CAP.PRICE_TYPE, CAP.RECUR_SCHEME_TYPE, CAP.RECUR_SCHEME_LENGTH, CAP.TRIAL_PRICE_ID, ".
				"	CAP.WITHOUT_ORDER, CAP.SELECT_BEST_PRICE, CAP.PURCHASING_PRICE, CAP.PURCHASING_CURRENCY, CAP.BARCODE_MULTI, ".
				"	CAP.TMP_ID ".
				"	".$strSelectPart." ".
				"FROM b_iblock_element BE, b_lang L, ".
				($bSections?"b_iblock_section_element BSE,":"").
				"	b_iblock B ".
				"	LEFT JOIN b_iblock_group IBG ON IBG.IBLOCK_ID = B.ID ".
				"	LEFT JOIN b_catalog_product CAP ON BE.ID = CAP.ID ".
				"	".$strFromPart." ".
				"WHERE BE.IBLOCK_ID = B.ID ".
				"	AND B.LID = L.LID ".
				($bSections?"	AND BSE.IBLOCK_ELEMENT_ID = BE.ID ":"").
				"	AND IBG.GROUP_ID IN (".$USER->GetGroups().") ".
				"	".CIBlockElement::WF_GetSqlLimit("BE.", $SHOW_NEW)." ".
				"	AND IBG.PERMISSION>='".(strlen($arFilter["MIN_PERMISSION"])==1 ? $arFilter["MIN_PERMISSION"] : "R")."' ".
				"	AND (IBG.PERMISSION='X' OR B.ACTIVE='Y') ".
				"	".$strSqlSearch." ";
		}
		else
		{
			$strSql =
				"SELECT BE.*, ".
				"	".$DB->DateToCharFunction("BE.TIMESTAMP_X")." as TIMESTAMP_X, ".
				"	".$DB->DateToCharFunction("BE.ACTIVE_FROM", "SHORT")." as ACTIVE_FROM, ".
				"	".$DB->DateToCharFunction("BE.ACTIVE_TO", "SHORT")." as ACTIVE_TO, ".
				"	".$DB->DateToCharFunction("BE.WF_DATE_LOCK")." as WF_DATE_LOCK, ".
				"	L.DIR as LANG_DIR, B.DETAIL_PAGE_URL, B.LIST_PAGE_URL, ".
				"	CAP.QUANTITY, CAP.QUANTITY_RESERVED, IF (CAP.QUANTITY_TRACE = 'D', '".$DB->ForSql(COption::GetOptionString('catalog','default_quantity_trace','N'))."', CAP.QUANTITY_TRACE)  as QUANTITY_TRACE, CAP.WEIGHT, ".
				"   IF (CAP.CAN_BUY_ZERO = 'D', '".$DB->ForSql(COption::GetOptionString('catalog','default_can_buy_zero','N'))."', CAP.CAN_BUY_ZERO) as CAN_BUY_ZERO, ".
				"   IF (CAP.NEGATIVE_AMOUNT_TRACE = 'D', '".$DB->ForSql(COption::GetOptionString('catalog','allow_negative_amount','N'))."', CAP.NEGATIVE_AMOUNT_TRACE) as NEGATIVE_AMOUNT_TRACE, ".
				"	CAP.VAT_ID, CAP.VAT_INCLUDED, ".
				"	CAP.PRICE_TYPE, CAP.RECUR_SCHEME_TYPE, CAP.RECUR_SCHEME_LENGTH, CAP.TRIAL_PRICE_ID, ".
				"	CAP.WITHOUT_ORDER, CAP.SELECT_BEST_PRICE, CAP.PURCHASING_PRICE, CAP.PURCHASING_CURRENCY, CAP.BARCODE_MULTI, ".
				"	CAP.TMP_ID ".
				"	".$strSelectPart." ".
				"FROM  b_iblock B, b_lang L, ".
				($bSections?"b_iblock_section_element BSE,":"").
				"	b_iblock_element BE ".
				"	LEFT JOIN b_catalog_product CAP ON BE.ID = CAP.ID ".
				"	".$strFromPart." ".
				"WHERE BE.IBLOCK_ID = B.ID ".
				($bSections?"	AND BSE.IBLOCK_ELEMENT_ID = BE.ID ":"").
				"	".CIBlockElement::WF_GetSqlLimit("BE.",$SHOW_NEW)." ".
				"	AND B.LID = L.LID ".
				"	".$strSqlSearch." ";
		}

		$arSqlOrder = array();
		foreach($arOrder as $by=>$order)
		{
			$by = strtoupper($by);
			$order = strtoupper($order);
			if ($order!="ASC") $order = "DESC";

			if ($by == "ID")				$arSqlOrder[] = " BE.ID ".$order." ";
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:101,代码来源:product.php

示例2: PrepareGetList


//.........这里部分代码省略.........
                 if (preg_match("/^([^.]+)\\.([^.]+)\$/", $PR_ID, $arMatch)) {
                     $db_prop = CIBlockProperty::GetPropertyArray($arMatch[1], CIBlock::_MergeIBArrays($arFilter["IBLOCK_ID"], $arFilter["IBLOCK_CODE"]));
                     if (is_array($db_prop) && $db_prop["PROPERTY_TYPE"] == "E") {
                         CIBlockElement::MkPropertySelect($arMatch, $db_prop, $arIBlockLongProps, $arIBlockConvProps, $arJoinProps, $arIBlockMultProps, $arIBlockNumProps, $bWasGroup, $sGroupBy, $sSelect, true);
                     }
                 } else {
                     if ($db_prop = CIBlockProperty::GetPropertyArray($PR_ID, CIBlock::_MergeIBArrays($arFilter["IBLOCK_ID"], $arFilter["IBLOCK_CODE"]))) {
                         CIBlockElement::MkPropertySelect($PR_ID, $db_prop, $arIBlockLongProps, $arIBlockConvProps, $arJoinProps, $arIBlockMultProps, $arIBlockNumProps, $bWasGroup, $sGroupBy, $sSelect, true);
                     }
                 }
             } elseif ($val == "*") {
                 $bStar = true;
             } elseif (substr($val, 0, 14) == "CATALOG_GROUP_") {
                 $arAddSelectFields[] = $val;
             } elseif (substr($val, 0, 21) == "CATALOG_STORE_AMOUNT_") {
                 $arAddSelectFields[] = $val;
             } elseif (isset($arProductFields[$val])) {
                 $arAddSelectFields[] = $val;
             } elseif ($val == "RATING_TOTAL_VALUE" || $val == "RATING_TOTAL_VOTES" || $val == "RATING_TOTAL_POSITIVE_VOTES" || $val == "RATING_TOTAL_NEGATIVE_VOTES") {
                 if (array_key_exists($val, $arDisplayedColumns)) {
                     continue;
                 }
                 $arDisplayedColumns[$val] = true;
                 $arSelectFields[$key] = $val;
                 $sSelect .= "," . preg_replace("/^RATING_/", "RV.", $val) . " as " . $val;
                 $arJoinProps["RV"] = true;
             } elseif ($val == "RATING_USER_VOTE_VALUE") {
                 if (array_key_exists($val, $arDisplayedColumns)) {
                     continue;
                 }
                 $arDisplayedColumns[$val] = true;
                 $arSelectFields[$key] = $val;
                 if (isset($USER) && is_object($USER)) {
                     $sSelect .= "," . $DB->IsNull('RVU.VALUE', '0') . " as " . $val;
                     $arJoinProps["RVU"] = true;
                 } else {
                     $sSelect .= ",0 as " . $val;
                 }
             }
         }
         if ($bStar) {
             foreach ($arIblockElementFields as $key => $val) {
                 if (array_key_exists($key, $arDisplayedColumns)) {
                     continue;
                 }
                 $arDisplayedColumns[$key] = true;
                 $arSelectFields[] = $key;
                 $sSelect .= "," . $val . " as " . $key;
             }
         } elseif ($sGroupBy == "") {
             //Try to add missing fields for correct URL translation (only then no grouping)
             if (array_key_exists("DETAIL_PAGE_URL", $arDisplayedColumns)) {
                 $arAddFields = array("LANG_DIR", "ID", "CODE", "EXTERNAL_ID", "IBLOCK_SECTION_ID", "IBLOCK_TYPE_ID", "IBLOCK_ID", "IBLOCK_CODE", "IBLOCK_EXTERNAL_ID", "LID");
             } elseif (array_key_exists("CANONICAL_PAGE_URL", $arDisplayedColumns)) {
                 $arAddFields = array("LANG_DIR", "ID", "CODE", "EXTERNAL_ID", "IBLOCK_SECTION_ID", "IBLOCK_TYPE_ID", "IBLOCK_ID", "IBLOCK_CODE", "IBLOCK_EXTERNAL_ID", "LID");
             } elseif (array_key_exists("SECTION_PAGE_URL", $arDisplayedColumns)) {
                 $arAddFields = array("LANG_DIR", "ID", "CODE", "EXTERNAL_ID", "IBLOCK_SECTION_ID", "IBLOCK_TYPE_ID", "IBLOCK_ID", "IBLOCK_CODE", "IBLOCK_EXTERNAL_ID", "LID");
             } elseif (array_key_exists("LIST_PAGE_URL", $arDisplayedColumns)) {
                 $arAddFields = array("LANG_DIR", "IBLOCK_TYPE_ID", "IBLOCK_ID", "IBLOCK_CODE", "IBLOCK_EXTERNAL_ID", "LID");
             } else {
                 $arAddFields = array();
             }
             //Try to add missing fields for correct PREVIEW and DETAIL text formatting
             if (array_key_exists("DETAIL_TEXT", $arDisplayedColumns)) {
                 $arAddFields[] = "DETAIL_TEXT_TYPE";
             }
             if (array_key_exists("PREVIEW_TEXT", $arDisplayedColumns)) {
                 $arAddFields[] = "PREVIEW_TEXT_TYPE";
             }
             foreach ($arAddFields as $key) {
                 if (array_key_exists($key, $arDisplayedColumns)) {
                     continue;
                 }
                 $arDisplayedColumns[$key] = true;
                 $arSelectFields[] = $key;
                 $sSelect .= "," . $arIblockElementFields[$key] . " as " . $key;
             }
         }
         if ($sGroupBy != "") {
             $sSelect = substr($sSelect, 1) . ", COUNT(%%_DISTINCT_%% BE.ID) as CNT ";
         } elseif (strlen($sSelect) > 0) {
             $sSelect = "%%_DISTINCT_%% " . substr($sSelect, 1) . " ";
         }
     }
     //*********************WHERE PART*********************
     $arAddWhereFields = array();
     if (is_array($arFilter) && array_key_exists("CATALOG", $arFilter)) {
         $arAddWhereFields = $arFilter["CATALOG"];
         unset($arFilter["CATALOG"]);
     }
     $arSqlSearch = CIBlockElement::MkFilter($arFilter, $arJoinProps, $arAddWhereFields);
     $bDistinct = false;
     $sSectionWhere = "";
     $sWhere = "";
     foreach ($arSqlSearch as $condition) {
         if (strlen(trim($condition, "\n\t")) > 0) {
             $sWhere .= "\n\t\t\tAND (" . $condition . ")";
         }
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:iblockelement.php


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