Ejemplo n.º 1
0
     $pg = 1;
 }
 $cacheid .= "." . $pg;
 if (!$smarty->is_cached($template, $cacheid)) {
     $offset = ($pg - 1) * $sphinx->pageSize + 1;
     if ($offset < 1000 - $pgsize) {
         $sphinx->processQuery();
         $sphinx->sort = "score ASC, @relevance DESC, @id DESC";
         #$sphinx->sort = -1;
         #$sphinx->_getClient()->SetSortMode(SPH_SORT_EXPR,"(10-score) * @weight");
         #			if (preg_match('/^\w+$/',$sphinx->q)) {
         #				$sphinx->qoutput = $sphinx->q;
         #				$sphinx->q = "{$sphinx->q} | {$sphinx->q}*"; //rank full matches first
         #			}
         if ($fuzzy) {
             $sphinx->_getClient()->SetIndexWeights(array('gaz' => 10, 'gaz_meta' => 1));
             $ids = $sphinx->returnIds($pg, 'gaz,gaz_meta');
         } else {
             $ids = $sphinx->returnIds($pg, 'gaz');
         }
         if (!empty($ids) && count($ids)) {
             $where = "id IN(" . join(",", $ids) . ")";
             $db = NewADOConnection($GLOBALS['DSN2']);
             $limit = 25;
             $prev_fetch_mode = $ADODB_FETCH_MODE;
             $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
             $rows = $db->getAssoc("\r\n\t\t\t\tselect id,name,name_2,gr,localities,localities_2,score\r\n\t\t\t\tfrom placename_index \r\n\t\t\t\twhere {$where}\r\n\t\t\t\tlimit {$limit}");
             $results = array();
             foreach ($ids as $c => $id) {
                 $row = $rows[$id];
                 $row['id'] = $id;