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


PHP Query::setOrder方法代码示例

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


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

示例1: getList

function getList($blockId, $fields, $order, $filers)
{
    $entity_requests_data_class = connectToBlock($blockId);
    $main_query_requests = new Entity\Query($entity_requests_data_class);
    $main_query_requests->setSelect($fields);
    //$main_query_requests->setSelect(array('ID','UF_TITLE'));
    if (!empty($order)) {
        $main_query_requests->setOrder($order);
    }
    if (!empty($filers)) {
        $main_query_requests->setFilter($filers);
        /*$main_query_requests->setFilter(
              array(
                  'UF_NAME'=>'Александр',
              )
          );*/
    }
    $result_requests = $main_query_requests->exec();
    $result_requests = new CDBResult($result_requests);
    $requests = array();
    while ($row_requests = $result_requests->Fetch()) {
        $requests[] = $row_requests;
        //массив выбранных элементов
    }
    return $requests;
}
开发者ID:spas-viktor,项目名称:books,代码行数:26,代码来源:block_funcs.php

示例2: elemGetEx

 function elemGetEx($elemId = false)
 {
     $hlHandler = $this->hlHandler;
     $getList = new Entity\Query($hlHandler);
     $getList->setSelect(array('*'));
     $getList->setOrder(array("ID" => "ASC"));
     if (!empty($elemId)) {
         $getList->setFilter(array("ID" => $elemId));
     }
     $result = $getList->exec();
     $result = new CDBResult($result);
     $arRes = array();
     while ($row = $result->Fetch()) {
         $arRes[] = $row;
     }
     return $arRes;
 }
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:17,代码来源:highloadblocks.php

示例3: getList

 public static function getList($parameters = array())
 {
     $query = new Query(static::getEntity());
     if (!isset($parameters['select'])) {
         $query->setSelect(array('*'));
     }
     foreach ($parameters as $param => $value) {
         switch ($param) {
             case 'select':
                 $query->setSelect($value);
                 break;
             case 'filter':
                 $query->setFilter($value);
                 break;
             case 'group':
                 $query->setGroup($value);
                 break;
             case 'order':
                 $query->setOrder($value);
                 break;
             case 'limit':
                 $query->setLimit($value);
                 break;
             case 'offset':
                 $query->setOffset($value);
                 break;
             case 'count_total':
                 $query->countTotal($value);
                 break;
             case 'options':
                 $query->setOptions($value);
                 break;
             case 'runtime':
                 foreach ($value as $name => $fieldInfo) {
                     $query->registerRuntimeField($name, $fieldInfo);
                 }
                 break;
             case 'data_doubling':
                 if ($value) {
                     $query->enableDataDoubling();
                 } else {
                     $query->disableDataDoubling();
                 }
                 break;
             default:
                 throw new Main\ArgumentException("Unknown parameter: " . $param, $param);
         }
     }
     return $query->exec();
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:50,代码来源:datamanager.php

示例4: getDepartmentAverageGraphData

 public static function getDepartmentAverageGraphData($deptId, Type\DateTime $dateFrom, Type\DateTime $dateTo, $interval, $section = null)
 {
     if (!in_array($interval, array('hour', 'day', 'month'), true)) {
         throw new Main\ArgumentException('Interval should be the "hour", or "day", or "month".');
     }
     $data = array();
     $sectionField = $section === null ? 'TOTAL' : $section;
     if ($interval === 'hour') {
         $query = new Entity\Query(DepartmentHourTable::getEntity());
         $query->setSelect(array('DEPT_ID', 'DATE' => 'HOUR', 'AVG_ACTIVITY' => $sectionField));
         $query->setFilter(array('=DEPT_ID' => $deptId, '><HOUR' => array(ConvertTimeStamp($dateFrom->getTimestamp(), 'FULL'), ConvertTimeStamp($dateTo->getTimestamp(), 'FULL'))));
         $keyFormat = 'Y-m-d H:00:00';
     } elseif ($interval === 'day') {
         $query = new Entity\Query(DepartmentDayTable::getEntity());
         $query->setSelect(array('DEPT_ID', 'DATE' => 'DAY', new Entity\ExpressionField('AVG_ACTIVITY', 'CASE WHEN %s > 0 THEN ROUND((%s / %s), 0) ELSE 0 END', array('ACTIVE_USERS', $sectionField, 'ACTIVE_USERS'))));
         $query->setFilter(array('=DEPT_ID' => $deptId, '><DAY' => array(ConvertTimeStamp($dateFrom->getTimestamp()), ConvertTimeStamp($dateTo->getTimestamp()))));
         $keyFormat = 'Y-m-d';
     } elseif ($interval === 'month') {
         $query = new Entity\Query(DepartmentDayTable::getEntity());
         $sqlHelper = Application::getConnection()->getSqlHelper();
         $monthExpression = array('data_type' => 'string', 'expression' => array(str_replace($sqlHelper->formatDate('YYYY-MM'), str_replace('%', '%%', $sqlHelper->formatDate('YYYY-MM')), $sqlHelper->formatDate('YYYY-MM', '%1$s')), 'DAY'));
         $query->registerRuntimeField('DATE', $monthExpression);
         $query->setSelect(array('DEPT_ID', 'DATE', new Entity\ExpressionField('AVG_ACTIVITY', 'ROUND(SUM(CASE WHEN %s > 0 THEN %s / %s ELSE 0 END), 0)', array('ACTIVE_USERS', $sectionField, 'ACTIVE_USERS'))));
         $query->setFilter(array('=DEPT_ID' => $deptId, '><DAY' => array(ConvertTimeStamp($dateFrom->getTimestamp()), ConvertTimeStamp($dateTo->getTimestamp()))));
         $query->setGroup(array('DEPT_ID', 'DATE'));
         $keyFormat = 'Y-m';
     }
     // and continue with main data
     $query->setOrder('DATE');
     $result = $query->exec();
     while ($row = $result->fetch()) {
         /** @var Type\DateTime[] $row */
         if (!is_object($row['DATE'])) {
             $key = $row['DATE'];
             $row['DATE'] = new Type\DateTime($row['DATE'], $keyFormat);
         } else {
             $key = $row['DATE']->format($keyFormat);
         }
         $data[$key] = $row;
     }
     if ($interval === 'hour') {
         // recount unique users from DAILY stats,
         // because there are empty records for each user
         // at this moment AVG_ACTIVITY is just sum of activity, and we should find average per user
         $dailyActiveUsers = array();
         $query = new Entity\Query(DepartmentDayTable::getEntity());
         $result = $query->addSelect('DAY')->addSelect('ACTIVE_USERS')->addFilter('=DEPT_ID', $deptId)->addFilter('><DAY', array(ConvertTimeStamp($dateFrom->getTimestamp()), ConvertTimeStamp($dateTo->getTimestamp())))->exec();
         while ($row = $result->fetch()) {
             /** @var Type\DateTime[] $row */
             $dailyActiveUsers[$row['DAY']->format('Y-m-d')] = $row['ACTIVE_USERS'];
         }
         foreach ($data as &$hourlyData) {
             /** @var Type\DateTime[] $hourlyData */
             if (!empty($dailyActiveUsers[$hourlyData['DATE']->format('Y-m-d')])) {
                 $hourlyData['AVG_ACTIVITY'] = round($hourlyData['AVG_ACTIVITY'] / $dailyActiveUsers[$hourlyData['DATE']->format('Y-m-d')]);
             }
         }
     }
     return $data;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:60,代码来源:ustat.php

示例5: sprintf

$contextMenu[] = array('TEXT' => Loc::getMessage('USER_VARS_ADD'), 'TITLE' => Loc::getMessage('USER_VARS_ADD'), 'LINK' => 'user_vars_edit.php?GROUP_ID=' . $dataGroup['ID'] . '&lang=' . LANGUAGE_ID, 'ICON' => 'btn_new');
$contextMenu[] = array('TEXT' => Loc::getMessage('USER_VARS_EDIT_GROUP'), 'TITLE' => Loc::getMessage('USER_VARS_EDIT_GROUP'), 'LINK' => 'user_vars_group_edit.php?ID=' . $dataGroup['ID'] . '&lang=' . LANGUAGE_ID, 'ICON' => 'btn_edit');
$varsMap = Model\VarsTable::getMap();
$headers = array(array('id' => 'ID', 'content' => 'ID', 'sort' => 'ID', 'default' => true), array('id' => 'NAME', 'content' => $varsMap['NAME']['title'], 'sort' => 'NAME', 'default' => true), array('id' => 'CODE', 'content' => $varsMap['CODE']['title'], 'sort' => 'CODE', 'default' => true), array('id' => 'VALUE', 'content' => $varsMap['VALUE']['title'], 'sort' => 'VALUE', 'default' => true), array('id' => 'DESCRIPTION', 'content' => $varsMap['DESCRIPTION']['title'], 'sort' => 'DESCRIPTION', 'default' => true));
$tableId = 'tbl_user_vars_list';
$adminSort = new CAdminSorting($tableId, 'NAME', 'asc');
$adminList = new CAdminList($tableId, $adminSort);
$adminList->addHeaders($headers);
if ($request->getQuery('mode') != 'list') {
    $context = new CAdminContextMenu($contextMenu);
}
$queryBuilder = new Entity\Query(Model\VarsTable::getEntity());
$queryBuilder->setSelect(array('ID', 'NAME', 'CODE', 'DESCRIPTION', 'VALUE'))->setFilter(array('GROUP_ID' => $dataGroup['ID']));
$sortBy = $request->getQuery('by') ? strtoupper($request->getQuery('by')) : 'ID';
$sortOrder = $request->getQuery('order') ?: 'asc';
$queryBuilder->setOrder(array($sortBy => $sortOrder));
$resultData = new CAdminResult($queryBuilder->exec(), $tableId);
$resultData->navStart();
$adminList->navText($resultData->getNavPrint(Loc::getMessage('PAGES')));
while ($item = $resultData->fetch()) {
    $row = $adminList->addRow($item['ID'], $item);
    $actions = array();
    $actions[] = array('ICON' => 'edit', 'TEXT' => Loc::GetMessage('USER_VARS_ACTION_EDIT_VAR'), 'ACTION' => $adminList->actionRedirect('user_vars_edit.php?ID=' . $item['ID'] . '&GROUP_ID=' . $dataGroup['ID']));
    $actions[] = array('ICON' => 'delete', 'TEXT' => Loc::getMessage('USER_VARS_ACTION_DELETE_VAR'), 'ACTION' => "if(confirm('" . Loc::getMessage('USER_VARS_DELETE_VAR_CONFIRM') . "')) " . $adminList->actionRedirect('user_vars_edit.php?action=delete&ID=' . $item['ID'] . '&GROUP_ID=' . $dataGroup['ID'] . '&' . bitrix_sessid_get()));
    $row->addActions($actions);
}
$prologType = $request->getQuery('mode') == 'list' ? 'prolog_js' : 'prolog';
require sprintf('%s%s', getenv('DOCUMENT_ROOT'), $includePath[$prologType]);
if ($prologType != 'prolog_js') {
    $context->show();
}
开发者ID:ASDAFF,项目名称:citfact.uservars,代码行数:31,代码来源:user_vars_list.php

示例6: GetRegionsIdsByNames

 public static function GetRegionsIdsByNames($arRegNames, $countryId = false)
 {
     if (self::isLocationProMigrated()) {
         try {
             $types = self::getTypes();
             $query = new Entity\Query(self::SELF_ENTITY_NAME);
             $fieldMap = array('RID' => 'REGION_ID', 'RNAME' => 'NAME.NAME', 'RSHORT_NAME' => 'NAME.SHORT_NAME');
             $selectFields = $fieldMap;
             $filterFields = array(array('LOGIC' => 'OR', 'RNAME' => $arRegNames, 'RSHORT_NAME' => $arRegNames), '=TYPE_ID' => $types['REGION'], '!=REGION_ID' => '0');
             if ($countryId = intval($countryId)) {
                 $filterFields['=COUNTRY_ID'] = $countryId;
             }
             // order
             $orderFields = array('RNAME' => 'asc', 'RSHORT_NAME' => 'asc');
             // group
             $groupFields = array('RID');
             $nameJoinCondition = array('=this.ID' => 'ref.LOCATION_ID');
             if (strlen($strLang)) {
                 $nameJoinCondition['=ref.LANGUAGE_ID'] = array('?', $strLang);
             }
             $query->registerRuntimeField('NAME', array('data_type' => self::NAME_ENTITY_NAME, 'reference' => $nameJoinCondition, 'join_type' => 'left'));
             $query->setSelect($selectFields);
             $query->setFilter($filterFields);
             $query->setOrder($orderFields);
             $query->setGroup($groupFields);
             $result = array();
             $res = $query->exec();
             while ($item = $res->fetch()) {
                 $result[strlen($item['RNAME']) ? $item['RNAME'] : $item['RSHORT_NAME']] = $item['RID'];
             }
             return $result;
         } catch (Exception $e) {
             return array();
         }
     } else {
         global $DB;
         $arResult = array();
         $arWhere = array();
         $arQueryFields = array('RL.NAME', 'RL.SHORT_NAME');
         if (is_array($arRegNames)) {
             foreach ($arRegNames as $regName) {
                 $regName = $DB->ForSql($regName);
                 foreach ($arQueryFields as $field) {
                     $arWhere[] = $field . " LIKE '" . $regName . "'";
                 }
             }
             if (count($arWhere) > 0) {
                 $strWhere = implode(' OR ', $arWhere);
                 $query = "\tSELECT RL.REGION_ID, RL.NAME, RL.SHORT_NAME\n\t\t\t\t\t\t\t\tFROM b_sale_location_region_lang RL ";
                 if ($countryId) {
                     $strWhere = 'L.COUNTRY_ID=\'' . intval($countryId) . '\' AND (' . $strWhere . ')';
                     $query .= "LEFT JOIN b_sale_location L ON L.REGION_ID=RL.REGION_ID ";
                 }
                 $query .= "WHERE " . $strWhere;
                 $query .= " GROUP BY RL.REGION_ID";
                 $query .= " ORDER BY RL.NAME, RL.SHORT_NAME";
                 $dbList = $DB->Query($query);
                 $arRegionsLang = array();
                 while ($arRegion = $dbList->Fetch()) {
                     if (strlen($arRegion["NAME"]) > 0) {
                         $idx = $arRegion["NAME"];
                     } else {
                         $idx = $arRegion["SHORT_NAME"];
                     }
                     $arResult[$idx] = $arRegion["REGION_ID"];
                 }
             }
         }
         return $arResult;
     }
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:71,代码来源:location.php

示例7: normalizeLocationList

 public static function normalizeLocationList($denormalizedList = array())
 {
     if (empty($denormalizedList)) {
         return array();
     }
     $useCodes = static::getUseCodes();
     $denormalizedList = array_flip($denormalizedList);
     $query = new Entity\Query('Bitrix\\Sale\\Location\\Location');
     $query->setSelect(array('PARENT_ID', 'ID', 'CODE', 'LNAME' => 'NAME.NAME'));
     $query->setFilter(array('NAME.LANGUAGE_ID' => LANGUAGE_ID));
     // tmp
     $query->setOrder(array('LEFT_MARGIN' => 'desc'));
     // important
     $res = $query->exec();
     // make table of children count for each node
     $relations = array();
     $selected = array();
     while ($item = $res->fetch()) {
         if (!isset($relations[$item['ID']]['name'])) {
             // tmp
             $relations[$item['ID']]['name'] = $item['LNAME'];
         }
         if (!isset($relations[$item['ID']]['total'])) {
             $relations[$item['ID']]['total'] = 0;
         }
         if (!isset($relations[$item['ID']]['selected'])) {
             $relations[$item['ID']]['selected'] = 0;
         }
         ///
         if ($item['PARENT_ID'] != 0) {
             if (!isset($relations[$item['PARENT_ID']]['total'])) {
                 $relations[$item['PARENT_ID']]['total'] = 0;
             }
             if (!isset($relations[$item['PARENT_ID']]['selected'])) {
                 $relations[$item['PARENT_ID']]['selected'] = 0;
             }
         }
         $relations[$item['PARENT_ID']]['total'] += 1 + $relations[$item['ID']]['total'];
         if (isset($denormalizedList[$item['ID']])) {
             $relations[$item['PARENT_ID']]['selected'] += 1 + $relations[$item['ID']]['selected'];
             $selected[$item['ID']] = $item;
         }
     }
     // now make up list of nodes which we`ll remove
     $removeItems = array();
     $removeChildrenOf = array();
     foreach ($relations as $id => $rel) {
         if ($rel['total'] > 0) {
             if ($rel['total'] == $rel['selected']) {
                 if (isset($selected[$id])) {
                     // item should be selected itself to remove its children
                     $removeChildrenOf[$id] = true;
                 }
             } elseif ($rel['selected'] > 0) {
                 // selected M of N of children, where M > 0, so remove item itself
                 $removeItems[$id] = true;
             }
         }
     }
     $normalized = array();
     foreach ($selected as $id => $item) {
         if (!($item['PARENT_ID'] && $removeChildrenOf[$item['PARENT_ID']]) && !$removeItems[$item['ID']]) {
             $normalized[] = $item[$useCodes ? 'CODE' : 'ID'];
         }
     }
     return $normalized;
 }
开发者ID:akniyev,项目名称:arteva.ru,代码行数:67,代码来源:connector.php

示例8: array

$limit = array('nPageSize' => $arParams['ROWS_PER_PAGE'], 'iNumPage' => is_set($_GET['PAGEN_1']) ? $_GET['PAGEN_1'] : 1, 'bShowAll' => true);
// sort
$sort_id = 'ID';
$sort_type = 'DESC';
if (!empty($_GET['sort_id']) && isset($fields[$_GET['sort_id']])) {
    $sort_id = $_GET['sort_id'];
}
if (!empty($_GET['sort_type']) && in_array($_GET['sort_type'], array('ASC', 'DESC'), true)) {
    $sort_type = $_GET['sort_type'];
}
// limit
$limit = array('nPageSize' => $arParams['ROWS_PER_PAGE'], 'iNumPage' => is_set($_GET['PAGEN_1']) ? $_GET['PAGEN_1'] : 1, 'bShowAll' => true);
// execute query
$main_query = new Entity\Query($entity);
$main_query->setSelect(array('*'));
$main_query->setOrder(array($sort_id => $sort_type));
//$main_query->setSelect($select)
//	->setFilter($filter)
//	->setGroup($group)
//	->setOrder($order)
//	->setOptions($options);
if (isset($limit['nPageTop'])) {
    $main_query->setLimit($limit['nPageTop']);
} else {
    $main_query->setLimit($limit['nPageSize']);
    $main_query->setOffset(($limit['iNumPage'] - 1) * $limit['nPageSize']);
}
//$main_query->setLimit($limit['nPageSize']);
//$main_query->setOffset(($limit['iNumPage']-1) * $limit['nPageSize']);
$result = $main_query->exec();
$result = new CDBResult($result);
开发者ID:Satariall,项目名称:izurit,代码行数:31,代码来源:component.php

示例9: CDBResult

<?php

if (!CModule::IncludeModule("highloadblock")) {
    return;
}
use Bitrix\Highloadblock as HL;
use Bitrix\Main\Entity;
$Set_ID = $_SESSION["WF_IBL_SETTINGS_ID"];
unset($_SESSION["WF_IBL_SETTINGS_ID"]);
//Creating default values
$hldata = HL\HighloadBlockTable::getById($Set_ID)->fetch();
$hlentity = HL\HighloadBlockTable::compileEntity($hldata);
$hlHandler = $hlentity->getDataClass();
$getList = new Entity\Query($hlHandler);
$getList->setSelect(array('*'));
$getList->setOrder(array("ID" => "ASC"));
$getList->setFilter(array("ID" => 1));
$result = $getList->exec();
$result = new CDBResult($result);
if ($row = $result->Fetch()) {
} else {
    $arData = array("UF_THEME" => "default", "UF_SHADOWS" => "default", "UF_BUTTONS" => "coral", "UF_BG" => "default");
    $hlHandler::add($arData);
}
$Brand_ID = $_SESSION["WF_IBL_BRANDS_ID"];
unset($_SESSION["WF_IBL_BRANDS_ID"]);
$hldata = HL\HighloadBlockTable::getById($Brand_ID)->fetch();
$hlentity = HL\HighloadBlockTable::compileEntity($hldata);
$hlHandler = $hlentity->getDataClass();
$sort = 100;
$arBrandsUt = array("1 Marka" => "ref_files/7e44ec9828b17ace0d8f75a349b8de43.png", "Apollo" => "ref_files/61441e895fdde98034964c624e295f90.png", "AquaVita" => "ref_files/9d8f6c21dbd87f76b88a8b35e3cd0572.png", "BAS" => "ref_files/7eaea2afe6729ef29a25aeb82aba2513.png", "Cersanit" => "ref_files/9fe61dfbd7454a7ee27e41e0066fd3ba.png", "EAGO" => "ref_files/7d6f158e6fba7b90963c489c218fb8ef.png", "Kolpa-san" => "ref_files/a1906e21f88ebf48c6550117fb77b69f.png", "Loranto" => "ref_files/794eda4bc38c0decfb66455b436919e2.png", "RELISAN" => "ref_files/a3a02d848afdf90036f1def792d5adaf.png", "Roca" => "ref_files/bddd67008a780c90950540be078685a0.png", "Triton" => "ref_files/f75713924bd7964c999de3fbea43c2de.png", "Vayer" => "ref_files/5841ebf40c33bc9858245adfe7336427.png", "IDDIS" => "ref_files/85f24f3d3a9da494f411baa869b9df69.png", "Grohe" => "ref_files/6a2820fa128435a333ca473d06a78895.png", "Hansgrohe" => "ref_files/82499c22bd8a60b4ced944606973a91a.png");
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:31,代码来源:hlfill.php

示例10: getLikesList

function getLikesList($element, $user = false, $photos = false)
{
    global $USER;
    $cacheTime = 3600;
    $cacheId = 'likes_' . $element;
    $cachePath = '/likes';
    $obCache = new CPHPCache();
    if ($obCache->InitCache($cacheTime, $cacheId, $cachePath)) {
        $vars = $obCache->GetVars();
        return $vars['data'];
    } else {
        global $CACHE_MANAGER;
        $CACHE_MANAGER->StartTagCache($cachePath);
        $CACHE_MANAGER->RegisterTag($cacheId);
        $requiredModules = array('highloadblock');
        foreach ($requiredModules as $requiredModule) {
            if (!CModule::IncludeModule($requiredModule)) {
                ShowError(GetMessage("F_NO_MODULE"));
                return 0;
            }
        }
        if ($photos) {
            foreach ($photos as $key => &$value) {
                $value = 'photo_' . $value;
            }
        }
        // hlblock info
        $hlblock_id = IB_LIKE;
        if (empty($hlblock_id)) {
            ShowError(GetMessage('HLBLOCK_LIST_NO_ID'));
            return 0;
        }
        $hlblock = HL\HighloadBlockTable::getById($hlblock_id)->fetch();
        if (empty($hlblock)) {
            ShowError('404');
            return 0;
        }
        $entity = HL\HighloadBlockTable::compileEntity($hlblock);
        // uf info
        $fields = $GLOBALS['USER_FIELD_MANAGER']->GetUserFields('HLBLOCK_' . $hlblock['ID'], 0, LANGUAGE_ID);
        // pagination
        $limit = array('nPageSize' => $arParams['ROWS_PER_PAGE'], 'iNumPage' => is_set($_GET['PAGEN_1']) ? $_GET['PAGEN_1'] : 1, 'bShowAll' => true);
        // sort
        $sort_id = 'ID';
        $sort_type = 'DESC';
        // execute query
        $main_query = new Entity\Query($entity);
        $main_query->setSelect(array('*'));
        if ($user) {
            $main_query->setFilter(array('UF_ELEMENT_ID' => $element, 'UF_USER_ID' => $user));
        } else {
            if ($photos) {
                $main_query->setFilter(array('UF_ELEMENT_ID' => $photos));
            } else {
                $main_query->setFilter(array('UF_ELEMENT_ID' => $element));
            }
        }
        $main_query->setOrder(array($sort_id => $sort_type));
        //$main_query->setSelect($select)
        //	->setFilter($filter)
        //	->setGroup($group)
        //	->setOrder($order)
        //	->setOptions($options);
        //$main_query->setLimit($limit['nPageSize']);
        //$main_query->setOffset(($limit['iNumPage']-1) * $limit['nPageSize']);
        $result = $main_query->exec();
        $result = new CDBResult($result);
        // build results
        $rows = array();
        $tableColumns = array();
        $liked = false;
        $userLike = false;
        while ($row = $result->Fetch()) {
            foreach ($row as $k => $v) {
                if ($k === 'UF_USER_ID' && $USER->IsAuthorized() && $v == $USER->GetID()) {
                    $liked = true;
                    $userLike = $row;
                }
                if ($k == 'ID') {
                    $tableColumns['ID'] = true;
                    continue;
                }
                $arUserField = $fields[$k];
                if ($arUserField["SHOW_IN_LIST"] != "Y") {
                    continue;
                }
                $html = call_user_func_array(array($arUserField["USER_TYPE"]["CLASS_NAME"], "getadminlistviewhtml"), array($arUserField, array("NAME" => "FIELDS[" . $row['ID'] . "][" . $arUserField["FIELD_NAME"] . "]", "VALUE" => htmlspecialcharsbx($v))));
                if ($html == '') {
                    $html = '&nbsp;';
                }
                $tableColumns[$k] = true;
                $row[$k] = $html;
            }
            $rows[] = $row;
        }
        $data = array('rows' => $rows, 'fields' => $fields, 'colums' => $tableColumns, 'liked' => $liked, 'userLike' => $userLike);
        $CACHE_MANAGER->EndTagCache();
        if ($obCache->StartDataCache()) {
            $obCache->EndDataCache(array("data" => $data));
        }
//.........这里部分代码省略.........
开发者ID:dayAlone,项目名称:MyQube,代码行数:101,代码来源:getList.php


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