public static function GetPropertyValues($IBLOCK_ID, $arElementFilter, $extMode = false, $propertyFilter = array()) { global $DB; $IBLOCK_ID = (int) $IBLOCK_ID; $VERSION = CIBlockElement::GetIBVersion($IBLOCK_ID); $propertyID = array(); if (isset($propertyFilter['ID'])) { $propertyID = is_array($propertyFilter['ID']) ? $propertyFilter['ID'] : array($propertyFilter['ID']); Collection::normalizeArrayValuesByInt($propertyID); } $arElementFilter["IBLOCK_ID"] = $IBLOCK_ID; $element = new CIBlockElement(); $element->strField = "ID"; $element->GetList(array(), $arElementFilter, false, false, array("ID")); if ($VERSION == 2) { $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tBEP.*\n\t\t\t\tFROM\n\t\t\t\t\t" . $element->sFrom . "\n\t\t\t\t\tINNER JOIN b_iblock_element_prop_s" . $IBLOCK_ID . " BEP ON BEP.IBLOCK_ELEMENT_ID = BE.ID\n\t\t\t\tWHERE 1=1 " . $element->sWhere . "\n\t\t\t\tORDER BY\n\t\t\t\t\tBEP.IBLOCK_ELEMENT_ID\n\t\t\t"; } else { $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tBE.ID IBLOCK_ELEMENT_ID\n\t\t\t\t\t,BEP.IBLOCK_PROPERTY_ID\n\t\t\t\t\t,BEP.VALUE\n\t\t\t\t\t,BEP.VALUE_NUM\n\t\t\t\t\t" . ($extMode ? ",BEP.ID PROPERTY_VALUE_ID\n\t\t\t\t\t\t,BEP.DESCRIPTION\n\t\t\t\t\t\t" : "") . "\n\t\t\t\tFROM\n\t\t\t\t\t" . $element->sFrom . "\n\t\t\t\t\tLEFT JOIN b_iblock_element_property BEP ON BEP.IBLOCK_ELEMENT_ID = BE.ID " . (!empty($propertyID) ? "AND BEP.IBLOCK_PROPERTY_ID IN (" . implode(', ', $propertyID) . ")" : "") . "WHERE 1=1 " . $element->sWhere . "\n\t\t\t\tORDER BY\n\t\t\t\t\tBEP.IBLOCK_ELEMENT_ID\n\t\t\t"; } $rs = new CIBlockPropertyResult($DB->Query($strSql)); $rs->setIBlock($IBLOCK_ID, $propertyID); $rs->setMode($extMode); return $rs; }
public static function GetPropertyValues($IBLOCK_ID, $arElementFilter, $extMode = false) { global $DB; $IBLOCK_ID = intval($IBLOCK_ID); $VERSION = CIBlockElement::GetIBVersion($IBLOCK_ID); $arElementFilter["IBLOCK_ID"] = $IBLOCK_ID; $element = new CIBlockElement; $element->strField = "ID"; $element->GetList(array(), $arElementFilter, false, false, array("ID")); if ($VERSION == 2) $strSql = " SELECT BEP.* FROM ".$element->sFrom." INNER JOIN b_iblock_element_prop_s".$IBLOCK_ID." BEP ON BEP.IBLOCK_ELEMENT_ID = BE.ID WHERE 1=1 ".$element->sWhere." ORDER BY BEP.IBLOCK_ELEMENT_ID "; else $strSql = " SELECT BE.ID IBLOCK_ELEMENT_ID ,BEP.IBLOCK_PROPERTY_ID ,BEP.VALUE ,BEP.VALUE_NUM ".($extMode ? ",BEP.ID PROPERTY_VALUE_ID ,BEP.DESCRIPTION " : "" )." FROM ".$element->sFrom." LEFT JOIN b_iblock_element_property BEP ON BEP.IBLOCK_ELEMENT_ID = BE.ID WHERE 1=1 ".$element->sWhere." ORDER BY BEP.IBLOCK_ELEMENT_ID "; $rs = new CIBlockPropertyResult($DB->Query($strSql)); $rs->setIBlock($IBLOCK_ID); $rs->setMode($extMode); return $rs; }