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


PHP CDBResult::initFromArray方法代码示例

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


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

示例1: query

 protected function query($build_parts)
 {
     // nosql support with new platform only
     if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/bitrix/d7.php")) {
         // check nosql configuration
         $configuration = $this->init_entity->getConnection()->getConfiguration();
         if (isset($configuration['handlersocket']['read'])) {
             $nosqlConnectionName = $configuration['handlersocket']['read'];
             $nosqlConnection = \Bitrix\Main\Application::getInstance()->getDbConnectionPool()->getConnection($nosqlConnectionName);
             $isNosqlCapable = NosqlPrimarySelector::checkQuery($nosqlConnection, $this);
             if ($isNosqlCapable) {
                 $nosqlResult = NosqlPrimarySelector::relayQuery($nosqlConnection, $this);
                 $result = new \CDBResult();
                 $result->initFromArray($nosqlResult);
                 return $result;
             }
         }
     }
     foreach ($build_parts as $k => &$v) {
         if (strlen($v)) {
             $v = $k . ' ' . $v;
         }
     }
     if (!empty($this->options)) {
         foreach ($this->options as $opt => $value) {
             $build_parts = str_replace('%' . $opt . '%', $value, $build_parts);
         }
     }
     $query = join("\n", $build_parts);
     list($query, $replaced_aliases) = $this->replaceSelectAliases($query);
     if ($this->count_total || !is_null($this->offset)) {
         $cnt_body_elements = $build_parts;
         // remove order
         unset($cnt_body_elements['ORDER BY']);
         $cnt_query = join("\n", $cnt_body_elements);
         // remove long aliases
         list($cnt_query, ) = $this->replaceSelectAliases($cnt_query);
         // select count
         $cnt_query = 'SELECT COUNT(1) AS TMP_ROWS_CNT FROM (' . $cnt_query . ') xxx';
         $result = $this->DB->query($cnt_query);
         $result = $result->fetch();
         $cnt = $result["TMP_ROWS_CNT"];
     }
     if (empty($this->limit)) {
         $result = $this->DB->query($query);
         $result->arReplacedAliases = $replaced_aliases;
     } elseif (!empty($this->limit) && is_null($this->offset)) {
         $query = $this->DB->topSql($query, intval($this->limit));
         $result = $this->DB->query($query);
         $result->arReplacedAliases = $replaced_aliases;
     } else {
         // main query
         $result = new \CDBResult();
         $result->arReplacedAliases = $replaced_aliases;
         $db_limit = array('nPageSize' => $this->limit, 'iNumPage' => $this->offset ? $this->offset / $this->limit + 1 : 1, 'bShowAll' => true);
         $result->navQuery($query, $cnt, $db_limit);
     }
     $this->last_query = $query;
     return $result;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:60,代码来源:query.php

示例2: executeComponent

 public function executeComponent()
 {
     if (!CModule::IncludeModule('intranet')) {
         ShowError(GetMessage('INTR_ISL_INTRANET_MODULE_NOT_INSTALLED'));
         return;
     }
     if (!CModule::IncludeModule('socialnetwork')) {
         return;
     }
     $showDepHeadAdditional = $this->arParams['SHOW_DEP_HEAD_ADDITIONAL'] == 'Y';
     $bNav = $this->arParams['SHOW_NAV_TOP'] == 'Y' || $this->arParams['SHOW_NAV_BOTTOM'] == 'Y';
     $isEnoughFiltered = $this->fillFilter();
     list($cntStartCacheId, $cntStart) = $this->getCacheIdWithDepartment();
     if ($this->arParams['SHOW_UNFILTERED_LIST'] == 'N' && !$this->bExcel && !$isEnoughFiltered) {
         $this->arResult['EMPTY_UNFILTERED_LIST'] = 'Y';
         $this->includeComponentTemplate();
         return;
     }
     $this->arParams['bCache'] = $cntStart == count($this->arFilter) && !$this->bExcel && $this->arParams['CACHE_TYPE'] == 'Y' && $this->arParams['CACHE_TIME'] > 0;
     $this->arResult['FILTER_VALUES'] = $this->arFilter;
     if (!$this->bExcel && $bNav) {
         CPageOption::SetOptionString("main", "nav_page_in_session", "N");
     }
     $bFromCache = false;
     if ($this->arParams['bCache']) {
         if ($bFromCache = $this->initCache($cntStartCacheId)) {
             $vars = $this->obCache->getVars();
             $this->arResult['USERS'] = $vars['USERS'];
             $this->arResult['DEPARTMENTS'] = $vars['DEPARTMENTS'];
             $this->arResult['DEPARTMENT_HEAD'] = $vars['DEPARTMENT_HEAD'];
             $this->arResult['USERS_NAV'] = $vars['USERS_NAV'];
             $strUserIDs = $vars['STR_USER_ID'];
         } else {
             $this->obCache->startDataCache();
             $this->getCacheManager()->startTagCache($this->cacheDir);
             $this->getCacheManager()->registerTag('intranet_users');
         }
     }
     if (!$bFromCache) {
         // get users list
         $obUser = new CUser();
         $arSelect = array('ID', 'ACTIVE', 'CONFIRM_CODE', 'DEP_HEAD', 'GROUP_ID', 'NAME', 'LAST_NAME', 'SECOND_NAME', 'LOGIN', 'EMAIL', 'LID', 'DATE_REGISTER', 'PERSONAL_PROFESSION', 'PERSONAL_WWW', 'PERSONAL_ICQ', 'PERSONAL_GENDER', 'PERSONAL_BIRTHDATE', 'PERSONAL_PHOTO', 'PERSONAL_PHONE', 'PERSONAL_FAX', 'PERSONAL_MOBILE', 'PERSONAL_PAGER', 'PERSONAL_STREET', 'PERSONAL_MAILBOX', 'PERSONAL_CITY', 'PERSONAL_STATE', 'PERSONAL_ZIP', 'PERSONAL_COUNTRY', 'PERSONAL_NOTES', 'WORK_COMPANY', 'WORK_DEPARTMENT', 'WORK_POSITION', 'WORK_WWW', 'WORK_PHONE', 'WORK_FAX', 'WORK_PAGER', 'WORK_STREET', 'WORK_MAILBOX', 'WORK_CITY', 'WORK_STATE', 'WORK_ZIP', 'WORK_COUNTRY', 'WORK_PROFILE', 'WORK_LOGO', 'WORK_NOTES', 'PERSONAL_BIRTHDAY', 'LAST_ACTIVITY_DATE', 'LAST_LOGIN', 'IS_ONLINE');
         $this->arResult['USERS'] = array();
         $this->arResult['DEPARTMENTS'] = array();
         $this->arResult['DEPARTMENT_HEAD'] = 0;
         // disable/enable appearing of department head on page
         if ($showDepHeadAdditional && !empty($this->arFilter['UF_DEPARTMENT']) && is_array($this->arFilter['UF_DEPARTMENT'])) {
             if ($this->arParams['bCache']) {
                 $this->getCacheManager()->registerTag('intranet_department_' . $this->arFilter['UF_DEPARTMENT'][0]);
             }
             $managerId = CIntranetUtils::GetDepartmentManagerID($this->arFilter['UF_DEPARTMENT'][0]);
             $appendManager = CUser::GetByID($managerId)->Fetch();
             if ($appendManager) {
                 $this->arResult['DEPARTMENT_HEAD'] = $appendManager['ID'];
                 $this->arFilter['!ID'] = $appendManager['ID'];
                 $this->arResult['USERS'][$appendManager['ID']] = $appendManager;
             }
         }
         $bDisable = false;
         if (CModule::IncludeModule('extranet')) {
             if (CExtranet::IsExtranetSite() && !CExtranet::IsExtranetAdmin()) {
                 $arIDs = array_merge(CExtranet::GetMyGroupsUsers(SITE_ID), CExtranet::GetPublicUsers());
                 if ($this->arParams['bCache']) {
                     $this->getCacheManager()->registerTag('extranet_public');
                     $this->getCacheManager()->registerTag('extranet_user_' . $this->getUser()->getID());
                 }
                 if (false !== ($key = array_search($this->getUser()->getID(), $arIDs))) {
                     unset($arIDs[$key]);
                 }
                 if (count($arIDs) > 0) {
                     $this->arFilter['ID'] = implode('|', array_unique($arIDs));
                 } else {
                     $bDisable = true;
                 }
             }
         }
         if ($bDisable) {
             $dbUsers = new CDBResult();
             $dbUsers->initFromArray(array());
         } else {
             $arListParams = array('SELECT' => array('UF_*'), 'ONLINE_INTERVAL' => static::LAST_ACTIVITY);
             if (!$this->bExcel && $this->arParams['USERS_PER_PAGE'] > 0) {
                 $arListParams['NAV_PARAMS'] = array('nPageSize' => $this->arParams['USERS_PER_PAGE'], 'bShowAll' => false);
             }
             $dbUsers = $obUser->GetList($sortBy = 'last_name', $sortDir = 'asc', $this->arFilter, $arListParams);
         }
         $strUserIDs = '';
         while ($arUser = $dbUsers->Fetch()) {
             $this->arResult['USERS'][$arUser['ID']] = $arUser;
             $strUserIDs .= ($strUserIDs === '' ? '' : '|') . $arUser['ID'];
         }
         $structure = CIntranetUtils::getStructure();
         $this->arResult['DEPARTMENTS'] = $structure['DATA'];
         $this->setDepWhereUserIsHead();
         $arAdmins = array();
         /** @noinspection PhpUndefinedVariableInspection */
         $rsUsers = CUser::GetList($o, $b, array("GROUPS_ID" => array(static::ADMIN_GROUP_ID)), array("SELECT" => array("ID")));
         while ($ar = $rsUsers->Fetch()) {
             $arAdmins[$ar["ID"]] = $ar["ID"];
         }
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:class.php


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