/** * Group results by an attribute. * * @param string $attribute The name of the attribute. * @param int $func Constant, applied to attribute value, one of the SPH_GROUPBY_ constants. * @param string $groupsort An optional clause controlling how the groups are sorted. */ public function setGroupBy($attribute, $func, $groupsort = "@group desc") { $this->sphinx->setGroupBy($attribute, $func, $groupsort); }
/** * @brief set grouping attribute and function, SQL-like syntax - 'group_by' * @param array $groupby * @return $this chain */ public function groupby($groupby = null) { $this->criteria->groupby = $groupby; // set groupby if ($groupby && is_array($groupby)) { $this->client->setGroupBy($groupby['field'], $groupby['mode'], $groupby['order']); } return $this; }
} elseif (!$fids) { showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1)); } if ($_G['adminid'] != '1' && $_G['setting']['search']['forum']['maxspm']) { if (DB::result_first("SELECT COUNT(*) FROM " . DB::table('common_searchindex') . " WHERE srchmod='{$srchmod}' AND dateline>'{$_G['timestamp']}'-60") >= $_G['setting']['search']['forum']['maxspm']) { showmessage('search_toomany', 'search.php?mod=forum', array('maxspm' => $_G['setting']['search']['forum']['maxspm'])); } } if ($srchtype == 'fulltext' && $_G['setting']['sphinxon']) { require_once libfile('class/sphinx'); $s = new SphinxClient(); $s->setServer($_G['setting']['sphinxhost'], intval($_G['setting']['sphinxport'])); $s->setMaxQueryTime(intval($_G['setting']['sphinxmaxquerytime'])); $s->SetRankingMode($_G['setting']['sphinxrank']); $s->setLimits(0, intval($_G['setting']['sphinxlimit']), intval($_G['setting']['sphinxlimit'])); $s->setGroupBy('tid', SPH_GROUPBY_ATTR); if ($srchfilter == 'digest') { $s->setFilterRange('digest', 1, 3, false); } if ($srchfilter == 'top') { $s->setFilterRange('displayorder', 1, 2, false); } else { $s->setFilterRange('displayorder', 0, 2, false); } if (!empty($srchfrom) && empty($srchtxt) && empty($srchuid) && empty($srchuname)) { $expiration = TIMESTAMP + $cachelife_time; $keywords = ''; if ($before) { $spx_timemix = 0; $spx_timemax = TIMESTAMP - $srchfrom; } else {
/** * @param \SphinxClient $sphinx */ public function bindToSphinx(\SphinxClient $sphinx) { $sphinx->setGroupBy($this->getAttr(), $this->getFunc(), $this->getGroupBy()); }