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


PHP SearchResult::numHits方法代码示例

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


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

示例1: exportRecordsFromSearchResultToArray

 /**
  * Export set of records from a given SearchResult object to an array of strings with the individual exports, keyed by primary key.
  * The behavior is tailored towards the needs of the OAIPMHService.
  *
  * @param string $ps_exporter_code defines the exporter to use
  * @param SearchResult $po_result search result as object
  * @param  array $pa_options
  * 		'start' =
  *   	'limit' =
  * @return array exported data
  */
 public static function exportRecordsFromSearchResultToArray($ps_exporter_code, $po_result, $pa_options = null)
 {
     $vn_start = isset($pa_options['start']) ? (int) $pa_options['start'] : 0;
     $vn_limit = isset($pa_options['limit']) ? (int) $pa_options['limit'] : 0;
     ca_data_exporters::$s_exporter_cache = array();
     ca_data_exporters::$s_exporter_item_cache = array();
     require_once __CA_LIB_DIR__ . '/core/Search/SearchResult.php';
     if (!$po_result instanceof SearchResult) {
         return false;
     }
     if (!($t_mapping = ca_data_exporters::loadExporterByCode($ps_exporter_code))) {
         return false;
     }
     if (sizeof(ca_data_exporters::checkMapping($ps_exporter_code)) > 0) {
         return false;
     }
     $t_instance = $t_mapping->getAppDatamodel()->getInstanceByTableNum($t_mapping->get('table_num'));
     if ($vn_start > 0 && $vn_start < $po_result->numHits()) {
         $po_result->seek($vn_start);
     }
     $va_return = array();
     $vn_i = 0;
     while ($po_result->nextHit()) {
         if ($vn_limit && $vn_i >= $vn_limit) {
             break;
         }
         $vn_pk_val = $po_result->get($t_instance->primaryKey());
         $va_return[$vn_pk_val] = ca_data_exporters::exportRecord($ps_exporter_code, $vn_pk_val);
         $vn_i++;
     }
     return $va_return;
 }
开发者ID:samrahman,项目名称:providence,代码行数:43,代码来源:ca_data_exporters.php

示例2: _getValues


//.........这里部分代码省略.........
                         $va_tag_vals[$vn_index][$vs_tag] = $vs_val;
                     }
                 }
             }
             if (isset($pa_options['sort']) && is_array($pa_options['sort']) && sizeof($pa_options['sort'])) {
                 $va_sortables = array();
                 foreach ($pa_options['sort'] as $vs_sort_spec) {
                     $va_sortables[] = $pr_res->get($vs_sort_spec, ['sortable' => true, 'returnAsArray' => true, 'returnBlankValues' => true]);
                 }
                 if (($vn_start > 0 || $vn_length > 0) && $vn_start < sizeof($va_sortables) && (!$vn_length || $vn_start + $vn_length <= sizeof($va_sortables))) {
                     $va_sortables = array_slice($va_sortables, $vn_start, $vn_length > 0 ? $vn_length : null);
                 }
                 if (is_array($va_sortables)) {
                     foreach ($va_sortables as $i => $va_sort_values) {
                         if (!is_array($va_sort_values)) {
                             continue;
                         }
                         foreach ($va_sort_values as $vn_index => $vs_sort_value) {
                             $va_tag_vals[$vn_index]['__sort__'] .= $vs_sort_value;
                         }
                     }
                 }
             }
             DisplayTemplateParser::$value_cache[$vs_cache_key] = $va_tag_vals;
             DisplayTemplateParser::$value_count_cache[$vs_cache_key] = $vn_count = sizeof($va_tag_vals);
         }
         if (strlen($pn_index)) {
             $va_tag_vals = $va_tag_vals[$pn_index];
             $vs_relative_to_container = null;
         }
     }
     $va_vals = [];
     for ($vn_c = 0; $vn_c < $vn_count; $vn_c++) {
         foreach (array_keys($pa_tags) as $vs_tag) {
             $vs_get_spec = $va_get_specs[$vs_tag]['spec'];
             $va_parsed_tag_opts = $va_get_specs[$vs_tag]['parsed'];
             switch (strtolower($vs_get_spec)) {
                 case 'relationship_typename':
                     $va_val_list = $pr_res->get('ca_relationship_types.preferred_labels.' . (caGetOption('orientation', $pa_options, 'LTOR') == 'LTOR' ? 'typename' : 'typename_reverse'), $va_opts = array_merge($pa_options, $va_parsed_tag_opts['options'], ['returnAsArray' => true, 'returnWithStructure' => false]));
                     break;
                 case 'relationship_type_id':
                     $va_val_list = $pr_res->get('ca_relationship_types.type_id', $va_opts = array_merge($pa_options, $va_parsed_tag_opts['options'], ['returnAsArray' => true, 'returnWithStructure' => false]));
                     break;
                 case 'relationship_typecode':
                 case 'relationship_type_code':
                     $va_val_list = $pr_res->get('ca_relationship_types.type_code', $va_opts = array_merge($pa_options, $va_parsed_tag_opts['options'], ['returnAsArray' => true, 'returnWithStructure' => false]));
                     break;
                 case 'date':
                     // allows embedding of current date
                     $va_val_list = [date(caGetOption('format', $va_parsed_tag_opts['options'], 'd M Y'))];
                     break;
                 case 'primary':
                     $va_val_list = [$pr_res->tableName()];
                     break;
                 case 'count':
                     $va_val_list = [$pr_res->numHits()];
                     break;
                 case 'omitcount':
                     $va_val_list = [(int) $pr_res->numHits() - ($vn_length - $vn_start)];
                     break;
                 case 'index':
                     $va_val_list = [$pr_res->currentIndex() + 1];
                     break;
                 default:
                     if (isset($pa_options['forceValues'][$vs_get_spec][$pr_res->getPrimaryKey()])) {
                         $va_val_list = [$pa_options['forceValues'][$vs_get_spec][$pr_res->getPrimaryKey()]];
                     } elseif ($vs_relative_to_container) {
                         $va_val_list = [$va_tag_vals[$vn_c][$vs_tag]];
                     } elseif (strlen($pn_index)) {
                         $va_val_list = [$va_tag_vals[$vs_tag]];
                     } else {
                         $va_val_list = $pr_res->get($vs_get_spec, $va_opts = array_merge($pa_options, $va_parsed_tag_opts['options'], ['returnAsArray' => true, 'returnWithStructure' => false]));
                         if (!is_array($va_val_list)) {
                             $va_val_list = array();
                         }
                         if (($vn_start > 0 || $vn_length > 0) && $vn_start < sizeof($va_val_list) && (!$vn_length || $vn_start + $vn_length <= sizeof($va_val_list))) {
                             $va_val_list = array_slice($va_val_list, $vn_start, $vn_length > 0 ? $vn_length : null);
                         }
                     }
                     break;
             }
             $ps_delimiter = caGetOption('delimiter', $va_opts, ';');
             if ($vs_relative_to_container) {
                 $va_vals[$vn_c][$vs_tag] = join($ps_delimiter, $va_val_list);
                 if (isset($va_tag_vals[$vn_c]['__sort__'])) {
                     $va_vals[$vn_c]['__sort__'] = $va_tag_vals[$vn_c]['__sort__'];
                 }
             } else {
                 if (!$pb_include_blanks) {
                     $va_val_list = array_filter($va_val_list, 'strlen');
                 }
                 $va_vals[$vs_tag] = join($ps_delimiter, $va_val_list);
                 if (isset($va_tag_vals[$vn_c]['__sort__'])) {
                     $va_vals['__sort__'] = $va_tag_vals[$vn_c]['__sort__'];
                 }
             }
         }
     }
     return $va_vals;
 }
开发者ID:samrahman,项目名称:providence,代码行数:101,代码来源:DisplayTemplateParser.php

示例3: numHits

 /**
  * Number of hits in the result set.
  * Overrides SearchResult::numHits() to implement result filtering
  */
 public function numHits()
 {
     if ($this->ops_filter_field) {
         $va_r = $this->getResultCountForFieldValues(array($this->ops_filter_field));
         $vn_num = 0;
         foreach ($this->opa_filter_values as $vm_value) {
             $vn_num += (int) $va_r[$this->ops_filter_field][$vm_value];
         }
         return $vn_num;
     }
     return parent::numHits();
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:16,代码来源:BaseSearchResult.php


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