Log in with username/password: lyceum/lyceum

Changeset 1025

Show
Ignore:
Timestamp:
03/04/07 19:09:14 (2 years ago)
Author:
jjb
Message:

Search works!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/lyceum/wp-includes/classes.php

    r1024 r1025  
    427427 
    428428      // If a search pattern is specified, load the posts that match 
     429      $search_join = false; 
    429430      if (!empty($q['s'])) { 
     431         $search_join = true; 
    430432         $q['s'] = addslashes_gpc($q['s']); 
    431433         $search = ' AND ('; 
     
    434436         $q['s'] = str_replace('"', ' ', $q['s']); 
    435437         $q['s'] = trim($q['s']); 
    436 /*        if ($q['exact']) { 
     438       if ($q['exact']) { 
    437439            $n = ''; 
    438440         } else { 
     
    442444            $s_array = explode(' ',$q['s']); 
    443445            $q['search_terms'] = $s_array; 
    444             $search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))'; 
     446            $search .= '(textdata LIKE \''.$n.$s_array[0].$n.'\')'; 
    445447            for ( $i = 1; $i < count($s_array); $i = $i + 1) { 
    446                $search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))'; 
    447             } 
    448             $search .= ' OR (post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\')'; 
     448               $search .= ' AND (textdata LIKE \''.$n.$s_array[$i].$n.'\')'; 
     449            } 
     450            $search .= ' OR (textdata LIKE \''.$n.$q['s'].$n.'\')'; 
    449451            $search .= ')'; 
    450452         } else { 
    451             $search = ' AND ((post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\'))'; 
    452          } 
    453          */ 
    454          // this is just raw basic functionality to work with new search table, need to add a lot more features 
    455          // (at least create parallel user-facing search syntax as wordpress) 
    456          $thesearchterms = $q['s']; 
    457 /*       not sure why this isn't working with the MATCH AGAINST notation 
    458          note: this version uses subquereis, which requires mysql 4.1 
    459          $search = " 
    460             AND (`$wpdb->posts`.`ID` IN ( 
    461                SELECT DISTINCT `post_id`  
    462                FROM `$wpdb->postsearch`  
    463                WHERE MATCH `textdata` AGAINST ('$thesearchterms' IN BOOLEAN MODE) 
    464             ))";*/ 
    465  
    466 // this will work most of the time 
    467          $searchresults = $wpdb->get_col(" 
    468             SELECT DISTINCT `post_id`  
    469             FROM `$wpdb->postsearch`  
    470             WHERE `textdata` LIKE '%$thesearchterms%' 
    471          "); 
    472  
    473          $searchresults = implode(',',$searchresults); 
    474  
    475          if ($searchresults) 
    476             $search = " 
    477                AND (`$wpdb->posts`.`ID` IN ($searchresults))"; 
     453            $search = ' AND (textdata LIKE \''.$n.$q['s'].$n.'\')'; 
     454         } 
    478455      } 
    479456 
     
    649626 
    650627      $where .= $blogblog; 
     628      if ($search_join) 
     629         $join .= " INNER JOIN $wpdb->postsearch ON ($wpdb->post2cat.post_id = $wpdb->postsearch.post_id) "; 
    651630      // Apply filters on where and join prior to paging so that any 
    652631      // manipulations to them are reflected in the paging by day queries. 
  • trunk/src/lyceum/wp-includes/template-functions-links.php

    r1003 r1025  
    492492            preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); 
    493493            $fromwhere = $matches[1]; 
    494             $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere"); 
     494            $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT $wpdb->posts.ID) FROM $fromwhere"); 
    495495            $max_page = $max_num_pages = ceil($numposts / $posts_per_page); 
    496496         } 
     
    536536            preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); 
    537537            $fromwhere = $matches[1]; 
    538             $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere"); 
     538            $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT $wpdb->posts.ID) FROM $fromwhere"); 
    539539            $max_num_pages = ceil($numposts / $posts_per_page); 
    540540         } 
Log in with username/password: lyceum/lyceum