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


PHP Query::setOffset方法代码示例

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


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

示例1: 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

示例2: getUsersTop

 public static function getUsersTop($userId, $departmentId, Type\DateTime $dateFrom, Type\DateTime $dateTo, $interval, $section = null, $nonInvolvedOnly = false, $from = 0, $limit = 100)
 {
     if (!in_array($interval, array('hour', 'day', 'month'), true)) {
         throw new Main\ArgumentException('Interval should be the "hour", or "day", or "month".');
     }
     $data = array();
     // rating for TOTAL activity or for an instrument
     $sumField = $section === null ? 'TOTAL' : $section;
     if ($interval === 'hour') {
         $query = new Entity\Query(UserHourTable::getEntity());
         $query->setSelect(array('USER_ID', new Entity\ExpressionField('SUM_' . $sumField, 'SUM(%s)', $sumField)));
         $query->setFilter(array('><HOUR' => array(ConvertTimeStamp($dateFrom->getTimestamp(), 'FULL'), ConvertTimeStamp($dateTo->getTimestamp(), 'FULL'))));
     } else {
         $query = new Entity\Query(UserDayTable::getEntity());
         $query->setSelect(array('USER_ID', new Entity\ExpressionField('SUM_' . $sumField, 'SUM(%s)', $sumField)));
         $query->setFilter(array('><DAY' => array(ConvertTimeStamp($dateFrom->getTimestamp()), ConvertTimeStamp($dateTo->getTimestamp()))));
     }
     if ($sumField == 'TOTAL') {
         // count number of used services
         $names = UserHourTable::getSectionNames();
         $fieldExpressions = array_fill(0, count($names), 'CASE WHEN SUM(%s) > 0 THEN 1 ELSE 0 END');
         $serviceCountExpression = join(' + ', $fieldExpressions);
         $query->addSelect(new Entity\ExpressionField('SERVICES_COUNT', $serviceCountExpression, $names));
         if ($nonInvolvedOnly) {
             // who didn't use 4 or more instruments
             $query->addFilter('<SERVICES_COUNT', static::INVOLVEMENT_SERVICE_COUNT);
         }
     } else {
         if ($nonInvolvedOnly) {
             // who didn't use instrument
             $query->addFilter('=SUM_' . $sumField, 0);
         } else {
             // who used it
             $query->addFilter('>SUM_' . $sumField, 0);
         }
     }
     $query->addOrder('SUM_' . $sumField, 'DESC');
     if (!$nonInvolvedOnly) {
         // we don't need this for non-involved users
         $query->registerRuntimeField('MYSELF', array('data_type' => 'integer', 'expression' => array('CASE WHEN %s = ' . (int) $userId . ' THEN 1 ELSE 0 END', 'USER_ID')));
         $query->addOrder('MYSELF', 'DESC');
     }
     $query->setOffset($from);
     $query->setLimit($limit);
     $result = $query->exec();
     while ($row = $result->fetch()) {
         $_data = array('USER_ID' => $row['USER_ID'], 'ACTIVITY' => $row['SUM_' . $sumField]);
         if ($sumField == 'TOTAL') {
             $_data['SERVICES_COUNT'] = $row['SERVICES_COUNT'];
             $_data['IS_INVOLVED'] = $row['SERVICES_COUNT'] >= static::INVOLVEMENT_SERVICE_COUNT;
         } else {
             $_data['SERVICES_COUNT'] = null;
             $_data['IS_INVOLVED'] = $row['SUM_' . $sumField] > 0;
         }
         $data[] = $_data;
     }
     return $data;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:58,代码来源:ustat.php

示例3: compatibleNavQuery

 function compatibleNavQuery(Query $query, array $arNavStartParams)
 {
     $cnt = $query->exec()->getSelectedRowsCount();
     // TODO check groups
     global $DB;
     if (isset($arNavStartParams["SubstitutionFunction"])) {
         $arNavStartParams["SubstitutionFunction"]($this, $query->getLastQuery(), $cnt, $arNavStartParams);
         return null;
     }
     if (isset($arNavStartParams["bDescPageNumbering"])) {
         $bDescPageNumbering = $arNavStartParams["bDescPageNumbering"];
     } else {
         $bDescPageNumbering = false;
     }
     $this->InitNavStartVars($arNavStartParams);
     $this->NavRecordCount = $cnt;
     if ($this->NavShowAll) {
         $this->NavPageSize = $this->NavRecordCount;
     }
     //calculate total pages depend on rows count. start with 1
     $this->NavPageCount = $this->NavPageSize > 0 ? floor($this->NavRecordCount / $this->NavPageSize) : 0;
     if ($bDescPageNumbering) {
         $makeweight = 0;
         if ($this->NavPageSize > 0) {
             $makeweight = $this->NavRecordCount % $this->NavPageSize;
         }
         if ($this->NavPageCount == 0 && $makeweight > 0) {
             $this->NavPageCount = 1;
         }
         //page number to display
         $this->NavPageNomer = $this->PAGEN < 1 || $this->PAGEN > $this->NavPageCount ? $_SESSION[$this->SESS_PAGEN] < 1 || $_SESSION[$this->SESS_PAGEN] > $this->NavPageCount ? $this->NavPageCount : $_SESSION[$this->SESS_PAGEN] : $this->PAGEN;
         //rows to skip
         $NavFirstRecordShow = 0;
         if ($this->NavPageNomer != $this->NavPageCount) {
             $NavFirstRecordShow += $makeweight;
         }
         $NavFirstRecordShow += ($this->NavPageCount - $this->NavPageNomer) * $this->NavPageSize;
         $NavLastRecordShow = $makeweight + ($this->NavPageCount - $this->NavPageNomer + 1) * $this->NavPageSize;
     } else {
         if ($this->NavPageSize > 0 && $this->NavRecordCount % $this->NavPageSize > 0) {
             $this->NavPageCount++;
         }
         //calculate total pages depend on rows count. start with 1
         if ($this->PAGEN >= 1 && $this->PAGEN <= $this->NavPageCount) {
             $this->NavPageNomer = $this->PAGEN;
         } elseif ($_SESSION[$this->SESS_PAGEN] >= 1 && $_SESSION[$this->SESS_PAGEN] <= $this->NavPageCount) {
             $this->NavPageNomer = $_SESSION[$this->SESS_PAGEN];
         } elseif ($arNavStartParams["checkOutOfRange"] !== true) {
             $this->NavPageNomer = 1;
         } else {
             return null;
         }
         //rows to skip
         $NavFirstRecordShow = $this->NavPageSize * ($this->NavPageNomer - 1);
         $NavLastRecordShow = $this->NavPageSize * $this->NavPageNomer;
     }
     $NavAdditionalRecords = 0;
     if (is_set($arNavStartParams, "iNavAddRecords")) {
         $NavAdditionalRecords = $arNavStartParams["iNavAddRecords"];
     }
     if (!$this->NavShowAll) {
         $query->setOffset($NavFirstRecordShow);
         $query->setLimit($NavLastRecordShow - $NavFirstRecordShow + $NavAdditionalRecords);
     }
     $res_tmp = $query->exec();
     //, $bIgnoreErrors);
     //		// Return false on sql errors (if $bIgnoreErrors == true)
     //		if ($bIgnoreErrors && ($res_tmp === false))
     //			return false;
     //		$this->result = $res_tmp->result;
     $this->DB = DB;
     if ($this->SqlTraceIndex) {
         $start_time = microtime(true);
     }
     $temp_arrray = array();
     $temp_arrray_add = array();
     $tmp_cnt = 0;
     while ($ar = $res_tmp->fetch()) {
         $tmp_cnt++;
         if (intval($NavLastRecordShow - $NavFirstRecordShow) > 0 && $tmp_cnt > $NavLastRecordShow - $NavFirstRecordShow) {
             $temp_arrray_add[] = $ar;
         } else {
             $temp_arrray[] = $ar;
         }
     }
     if ($this->SqlTraceIndex) {
         /** @noinspection PhpUndefinedVariableInspection */
         $exec_time = round(microtime(true) - $start_time, 10);
         $DB->addDebugTime($this->SqlTraceIndex, $exec_time);
         $DB->timeQuery += $exec_time;
     }
     $this->arResult = !empty($temp_arrray) ? $temp_arrray : false;
     $this->arResultAdd = !empty($temp_arrray_add) ? $temp_arrray_add : false;
     $this->nSelectedCount = $cnt;
     $this->bDescPageNumbering = $bDescPageNumbering;
     $this->bFromLimited = true;
     return null;
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:98,代码来源:compatible.php

示例4: createQuery

 /**
  * @return Main\Entity\Query
  */
 private function createQuery($offset = 0, $limit = 0)
 {
     if (!is_int($offset)) {
         $offset = intval($offset);
     }
     if (!is_int($limit)) {
         $limit = intval($limit);
     }
     $typeIDs = $this->getTypeIDs();
     if (empty($typeIDs)) {
         throw new Main\NotSupportedException("Criterion types are required.");
     }
     $query = new Main\Entity\Query(Entity\DuplicateIndexTable::getEntity());
     $query->addSelect('ROOT_ENTITY_ID');
     $query->addSelect('ROOT_ENTITY_NAME');
     $query->addSelect('ROOT_ENTITY_TITLE');
     $query->addSelect('QUANTITY');
     $query->addSelect('TYPE_ID');
     $query->addSelect('MATCHES');
     $query->addSelect('IS_JUNK');
     $permissionSql = '';
     if ($this->enablePermissionCheck) {
         $permissions = \CCrmPerms::GetUserPermissions($this->userID);
         $permissionSql = \CCrmPerms::BuildSql(\CCrmOwnerType::ResolveName($this->entityTypeID), '', 'READ', array('RAW_QUERY' => true, 'PERMS' => $permissions));
         if ($permissionSql === false) {
             //Access denied;
             return null;
         }
     }
     $query->addFilter('=USER_ID', $this->userID);
     $query->addFilter('=ENTITY_TYPE_ID', $this->entityTypeID);
     $query->addFilter('@TYPE_ID', $typeIDs);
     if ($this->enablePermissionCheck && $permissionSql !== '') {
         $query->addFilter('@ROOT_ENTITY_ID', new Main\DB\SqlExpression($permissionSql));
     }
     if ($offset > 0) {
         $query->setOffset($offset);
     }
     if ($limit > 0) {
         $query->setLimit($limit);
     }
     $enableSorting = $this->sortTypeID !== DuplicateIndexType::UNDEFINED;
     if ($enableSorting) {
         $order = $this->sortOrder === SORT_DESC ? 'DESC' : 'ASC';
         if ($this->sortTypeID === DuplicateIndexType::COMMUNICATION_EMAIL) {
             $query->addOrder('ROOT_ENTITY_EMAIL_FLAG', $order);
             $query->addOrder('ROOT_ENTITY_EMAIL', $order);
         } elseif ($this->sortTypeID === DuplicateIndexType::COMMUNICATION_PHONE) {
             $query->addOrder('ROOT_ENTITY_PHONE_FLAG', $order);
             $query->addOrder('ROOT_ENTITY_PHONE', $order);
         } elseif ($this->sortTypeID === DuplicateIndexType::PERSON) {
             $query->addOrder('ROOT_ENTITY_NAME_FLAG', $order);
             $query->addOrder('ROOT_ENTITY_NAME', $order);
         } elseif ($this->sortTypeID === DuplicateIndexType::ORGANIZATION) {
             $query->addOrder('ROOT_ENTITY_TITLE_FLAG', $order);
             $query->addOrder('ROOT_ENTITY_TITLE', $order);
         }
     }
     return $query;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:63,代码来源:duplicatelist.php

示例5: getList

 /**
  * @return DedupeDataSourceResult
  */
 public function getList($offset, $limit)
 {
     $result = new DedupeDataSourceResult();
     $typeID = $this->typeID;
     $entityTypeID = $this->getEntityTypeID();
     $enablePermissionCheck = $this->isPermissionCheckEnabled();
     //$userID = $this->getUserID();
     $query = new Main\Entity\Query(Entity\DuplicateEntityMatchHashTable::getEntity());
     $query->addSelect('MATCH_HASH');
     $query->addGroup('MATCH_HASH');
     $query->addOrder('MATCH_HASH', 'ASC');
     $query->registerRuntimeField('', new Main\Entity\ExpressionField('QTY', 'COUNT(*)'));
     $query->addSelect('QTY');
     $query->addFilter('>QTY', 1);
     $query->addFilter('=ENTITY_TYPE_ID', $entityTypeID);
     $query->addFilter('=TYPE_ID', $typeID);
     $permissionSql = '';
     if ($enablePermissionCheck) {
         $permissionSql = $this->preparePermissionSql();
         if ($permissionSql === false) {
             //Access denied;
             return $result;
         }
         if ($permissionSql !== '') {
             $query->addFilter('@ENTITY_ID', new Main\DB\SqlExpression($permissionSql));
         }
     }
     if (!is_int($offset)) {
         $offset = (int) $offset;
     }
     if ($offset > 0) {
         $query->setOffset($offset);
     }
     if (!is_int($limit)) {
         $limit = (int) $limit;
     }
     if ($limit > 0) {
         $query->setLimit($limit);
     }
     $dbResult = $query->exec();
     $processedItemCount = 0;
     $lightHashes = array();
     $heavyHashes = array();
     while ($fields = $dbResult->fetch()) {
         $processedItemCount++;
         $quantity = isset($fields['QTY']) ? (int) $fields['QTY'] : 0;
         $matchHash = isset($fields['MATCH_HASH']) ? $fields['MATCH_HASH'] : '';
         if ($matchHash === '' || $quantity < 2) {
             continue;
         }
         if ($quantity <= 100) {
             $lightHashes[] = $matchHash;
         } else {
             $heavyHashes[] = $matchHash;
         }
     }
     $result->setProcessedItemCount($processedItemCount);
     $map = array();
     if (!empty($heavyHashes)) {
         foreach ($heavyHashes as $matchHash) {
             $query = new Main\Entity\Query(Entity\DuplicateEntityMatchHashTable::getEntity());
             $query->addSelect('ENTITY_ID');
             $query->addSelect('IS_PRIMARY');
             $query->addFilter('=ENTITY_TYPE_ID', $entityTypeID);
             $query->addFilter('=TYPE_ID', $typeID);
             $query->addFilter('=MATCH_HASH', $matchHash);
             if ($enablePermissionCheck && $permissionSql !== '') {
                 $query->addFilter('@ENTITY_ID', new Main\DB\SqlExpression($permissionSql));
             }
             $query->setOffset(0);
             $query->setLimit(100);
             $dbResult = $query->exec();
             while ($fields = $dbResult->fetch()) {
                 $entityID = isset($fields['ENTITY_ID']) ? (int) $fields['ENTITY_ID'] : 0;
                 if ($entityID <= 0) {
                     continue;
                 }
                 if (!isset($map[$matchHash])) {
                     $map[$matchHash] = array();
                 }
                 $isPrimary = isset($fields['IS_PRIMARY']) && $fields['IS_PRIMARY'] === 'Y';
                 if ($isPrimary) {
                     if (!isset($map[$matchHash]['PRIMARY'])) {
                         $map[$matchHash]['PRIMARY'] = array();
                     }
                     $map[$matchHash]['PRIMARY'][] = $entityID;
                 } else {
                     if (!isset($map[$matchHash]['SECONDARY'])) {
                         $map[$matchHash]['SECONDARY'] = array();
                     }
                     $map[$matchHash]['SECONDARY'][] = $entityID;
                 }
             }
         }
     }
     if (!empty($lightHashes)) {
         $query = new Main\Entity\Query(Entity\DuplicateEntityMatchHashTable::getEntity());
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:matchhashdedupedatasource.php

示例6: array

// 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);
// build results
$rows = array();
$tableColumns = array();
while ($row = $result->Fetch()) {
    foreach ($row as $k => $v) {
        if ($k == 'ID') {
            $tableColumns['ID'] = true;
            continue;
        }
        $arUserField = $fields[$k];
开发者ID:Satariall,项目名称:izurit,代码行数:31,代码来源:component.php


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