public function fetch($filter, $params = array()) { // ����������� ������ ksort($filter); foreach ($filter as &$f) { if (is_array($f)) { sort($f); } } // ��������� � id ���� ��� ��������� ��������� $cacheId = serialize($filter); if (isset($params['count'])) { $cacheId .= '+cnt' . $params['count']; } if (isset($params['pageSize'])) { $cacheId .= '+ps' . $params['pageSize'] . '-' . CDBResult::navStringForCache($params['pageSize']); } if (isset($params['sort'])) { $cacheId .= '+s' . serialize($params['sort']); } else { $params['sort'] = array('id' => 'desc'); } // ��������� ��� $cache = new CPhpCache(); if (false && $cache->initCache($this->_cacheTime, $cacheId, $this->_cacheDir)) { $vars = $cache->getVars(); // ��� ����, ����� ������������ ����������� ���������, ��������� CDBResult $this->_dbResult = new CDBResult(); if (isset($params['pageSize'])) { $this->_dbResult->InitFromArray((int) $vars['total'] > 0 ? array_fill(0, $vars['total'], 0) : array()); if (isset($params['pageSize'])) { $this->_dbResult->navStart($params['pageSize'], true, $vars['page']); } } return $vars['items']; } // � ���� ��� CMOdule::includeModule('iblock'); $filter['IBLOCK_ID'] = isset($filter['IBLOCK_ID']) ? $filter['IBLOCK_ID'] : $this->_iblockId; $filter['ACTIVE'] = 'Y'; $this->_dbResult = CIBlockElement::getList($params['sort'], $filter, false, isset($params['count']) ? array('nTopCount' => $params['count']) : false, $this->_commonSelect); if (isset($params['pageSize'])) { $this->_dbResult->navStart($params['pageSize']); } $result = array(); while ($row = $this->_dbResult->fetch()) { $result[$row['ID']] = $row; } if ($cache->startDataCache()) { $cache->endDataCache(array('items' => $result, 'total' => $this->_dbResult->NavRecordCount, 'page' => $this->_dbResult->NavPageNomer)); } return $result; }
public function getLastUrl() { $cacheTime = 3600; $cacheId = "last_issue_url"; $cacheDir = SITE_ID . '/issues'; $cache = new CPhpCache(); if ($cache->initCache($cacheTime, $cacheId, $cacheDir)) { return $cache->getVars(); } CModule::IncludeModule("iblock"); $arFilter = array("IBLOCK_ID" => $this->_iblock, 'ACTIVE_DATE' => "Y"); $res = CIBlockElement::GetList(array("ACTIVE_FROM" => "DESC"), $arFilter, false, array("nTopCount" => 1), array("ID")); $arIssues = array(); if ($arIssue = $res->GetNext()) { $url = \MH\FrontSite::o()->router->makeUrl('issues_issue', array('ID' => $arIssue['ID'])); } if ($cache->startDataCache()) { $cache->endDataCache($url); } return $url; }
protected function _determineModules(array $ids) { sort($ids); $cache = new CPhpCache(); if ($cache->initCache($this->_cacheTime, serialize($ids), $this->_cacheDir)) { return $cache->getVars(); } CModule::includeModule('iblock'); $res = CIBlockElement::getList(array(), array('ID' => $ids), false, array('nTopCount' => count($ids)), array('ID', 'IBLOCK_ID')); $result = array(); while ($row = $res->fetch()) { $module = $this->_getModule($row['IBLOCK_ID']); if (!array_key_exists($module, $result)) { $result[$module] = array(); } $result[$module][] = $row['ID']; } if ($cache->startDataCache()) { $cache->endDataCache($result); } return $result; }