本文整理汇总了PHP中CSaleLocation::processSelectForGetList方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleLocation::processSelectForGetList方法的具体用法?PHP CSaleLocation::processSelectForGetList怎么用?PHP CSaleLocation::processSelectForGetList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleLocation
的用法示例。
在下文中一共展示了CSaleLocation::processSelectForGetList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetLocationList
/**
* <p>Метод возвращает набор местоположений, связанных с группами местоположений, удовлетворяющих фильтру arFilter. Метод динамичный.</p>
*
*
* @param array $arrayarFilter = Array() Фильтр представляет собой ассоциативный массив, в котором
* ключами являются названия параметров записи, а значениями -
* условия на значения<br><br> Допустимые ключи: <ul> <li> <b>LOCATION_ID</b> - код
* местоположения;</li> <li> <b>LOCATION_GROUP_ID</b> - код группы
* местоположений.</li> </ul>
*
* @return CDBResult <p>Возвращается объект класса CDBResult, содержащий ассоциативные
* массивы с ключами:</p> <table class="tnormal" width="100%"> <tr> <th width="15%">Ключ</th>
* <th>Описание</th> </tr> <tr> <td>LOCATION_ID</td> <td>Код местоположения.</td> </tr> <tr>
* <td>LOCATION_GROUP_ID</td> <td>Код группы местоположений.</td> </tr> </table> <a
* name="examples"></a>
*
* <h4>Example</h4>
* <pre>
* <?
* // Выберем все местоположения группы 2
* $db_res = CSaleLocationGroup::GetLocationList(array("LOCATION_GROUP_ID"=>2));
* while ($ar_res = $db_res->Fetch())
* {
* echo $ar_res["LOCATION_ID"].", ";
* }
* ?>
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalelocationgroup/csalelocationgroup__getlocationlist.56a02620.php
* @author Bitrix
*/
public static function GetLocationList($arFilter = array())
{
if (CSaleLocation::isLocationProMigrated()) {
try {
$query = new Entity\Query(self::CONN_ENTITY_NAME);
$fieldMap = array('D_SPIKE' => 'D_SPIKE', 'LLOCATION_ID' => 'C.ID', 'LOCATION_GROUP_ID' => 'LOCATION_GROUP_ID');
$fieldProxy = array('LLOCATION_ID' => 'LOCATION_ID');
$query->registerRuntimeField('D_SPIKE', array('data_type' => 'integer', 'expression' => array('distinct %s', 'LOCATION_GROUP_ID')));
$query->registerRuntimeField('L', array('data_type' => self::LOCATION_ENTITY_NAME, 'reference' => array('=this.LOCATION_ID' => 'ref.ID'), 'join_type' => 'inner'));
$query->registerRuntimeField('C', array('data_type' => self::LOCATION_ENTITY_NAME, 'reference' => array('LOGIC' => 'OR', array('>=ref.LEFT_MARGIN' => 'this.L.LEFT_MARGIN', '<=ref.RIGHT_MARGIN' => 'this.L.RIGHT_MARGIN'), array('=ref.ID' => 'this.L.ID')), 'join_type' => 'inner'));
// select
$selectFields = CSaleLocation::processSelectForGetList(array('*'), $fieldMap);
// filter
list($filterFields, $filterClean) = CSaleLocation::processFilterForGetList($arFilter, $fieldMap, $fieldProxy);
$query->setSelect($selectFields);
$query->setFilter($filterFields);
$res = $query->exec();
$res->addReplacedAliases(array('LLOCATION_ID' => 'LOCATION_ID'));
return $res;
} catch (Exception $e) {
return new DB\ArrayResult(array());
}
} else {
global $DB;
$arSqlSearch = array();
if (!is_array($arFilter)) {
$filter_keys = array();
} else {
$filter_keys = array_keys($arFilter);
}
$countFieldKey = count($filter_keys);
for ($i = 0; $i < $countFieldKey; $i++) {
$val = $DB->ForSql($arFilter[$filter_keys[$i]]);
if (strlen($val) <= 0) {
continue;
}
$key = $filter_keys[$i];
if ($key[0] == "!") {
$key = substr($key, 1);
$bInvert = true;
} else {
$bInvert = false;
}
switch (ToUpper($key)) {
case "LOCATION_ID":
$arSqlSearch[] = "LOCATION_ID " . ($bInvert ? "<>" : "=") . " " . IntVal($val) . " ";
break;
case "LOCATION_GROUP_ID":
$arSqlSearch[] = "LOCATION_GROUP_ID " . ($bInvert ? "<>" : "=") . " " . IntVal($val) . " ";
break;
}
}
$strSqlSearch = "";
$countSqlSearch = count($arSqlSearch);
for ($i = 0; $i < $countSqlSearch; $i++) {
$strSqlSearch .= " AND ";
$strSqlSearch .= " (" . $arSqlSearch[$i] . ") ";
}
$strSql = "SELECT LOCATION_ID, LOCATION_GROUP_ID " . "FROM b_sale_location2location_group " . "WHERE 1 = 1 " . "\t" . $strSqlSearch . " ";
$res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
return $res;
}
}
示例2: getDenormalizedLocationList
public static function getDenormalizedLocationList($entityName, $arFilter = array())
{
$class = $entityName.'Table';
$linkField = $class::getLinkField();
$typeField = $class::getTypeField();
$locationLinkField = $class::getLocationLinkField();
$useGroups = $class::getUseGroups();
$query = new Entity\Query($entityName);
$fieldMap = array(
'D_SPIKE' => 'D_SPIKE',
'RLOCATION_ID' => 'RLOCATION_ID',
'LCOUNTRY_ID' => 'C.ID',
'LREGION_ID' => 'C.REGION_ID',
'LCITY_ID' => 'C.CITY_ID',
$linkField => $linkField
);
if($useGroups)
{
$fieldMap['LLOCATION_TYPE'] = $typeField;
}
$fieldProxy = array(
'LLOCATION_ID' => $locationLinkField
);
if($useGroups)
$fieldProxy['LLOCATION_TYPE'] = 'LOCATION_TYPE';
$query->registerRuntimeField(
'D_SPIKE',
array(
'data_type' => 'integer',
'expression' => array(
'distinct %s',
$linkField
)
)
);
/////////////////////////////////////////////////
// denormalized
$joinCondition = array(
self::getTypeJOINCondition('ref'),
'=this.'.$locationLinkField => 'ref.ID',
);
if($useGroups)
$joinCondition['=this.'.$typeField] = array('?', Location\Connector::DB_LOCATION_FLAG);
$types = self::getTypes();
$query->registerRuntimeField(
'L',
array(
'data_type' => self::SELF_ENTITY_NAME,
'reference' => $joinCondition,
'join_type' => 'left'
)
);
$query->registerRuntimeField(
'C',
array(
'data_type' => self::SELF_ENTITY_NAME,
'reference' => array(
'LOGIC' => 'OR',
array(
self::getTypeJOINCondition('ref'),
'>=ref.LEFT_MARGIN' => 'this.L.LEFT_MARGIN',
'<=ref.RIGHT_MARGIN' => 'this.L.RIGHT_MARGIN'
),
/*
array(
'=ref.ID' => 'this.L.ID'
)
*/
),
'join_type' => 'left'
)
);
$query->registerRuntimeField(
'RLOCATION_ID',
array(
'data_type' => 'integer',
'expression' => array(
'case when %s is null then %s else %s end',
'C.ID',
'LOCATION_ID',
'C.ID'
)
)
);
// select
$selectFields = CSaleLocation::processSelectForGetList(array('*'), $fieldMap);
// filter
list($filterFields, $filterClean) = CSaleLocation::processFilterForGetList($arFilter, $fieldMap, $fieldProxy, $query);
//.........这里部分代码省略.........