includes/search.php
changeset 499 6b7fdd898ba3
parent 461 717e71109645
child 507 586fd7d3202d
equal deleted inserted replaced
498:a85af9c28355 499:6b7fdd898ba3
   108  *   namespace: string, self-explanatory
   108  *   namespace: string, self-explanatory
   109  *   page_length: integer, the length of the full page in bytes
   109  *   page_length: integer, the length of the full page in bytes
   110  *   page_text: string, the contents of the page (trimmed to ~150 bytes if necessary)
   110  *   page_text: string, the contents of the page (trimmed to ~150 bytes if necessary)
   111  *   score: numerical relevance score, 1-100, rounded to 2 digits and calculated based on which terms were present and which were not
   111  *   score: numerical relevance score, 1-100, rounded to 2 digits and calculated based on which terms were present and which were not
   112  * @param string Search query
   112  * @param string Search query
   113  * @param string Will be filled with any warnings encountered whilst parsing the query
   113  * @param string|reference Will be filled with any warnings encountered whilst parsing the query
   114  * @param bool Case sensitivity - defaults to false
   114  * @param bool Case sensitivity - defaults to false
   115  * @param array|reference Will be filled with the parsed list of words.
   115  * @param array|reference Will be filled with the parsed list of words.
   116  * @return array
   116  * @return array
   117  */
   117  */
   118 
   118 
   195       if ( !$case_sensitive )
   195       if ( !$case_sensitive )
   196         $term = strtolower($term);
   196         $term = strtolower($term);
   197       $where_any[] = $term;
   197       $where_any[] = $term;
   198     }
   198     }
   199 
   199 
   200     $col_word = ( $case_sensitive ) ? 'word' : ENANO_SQLFUNC_LOWERCASE . '(word)';
   200     $col_word = ( $case_sensitive ) ? 'word' : 'word_lcase';
   201     $where_any = ( count($where_any) > 0 ) ? '( ' . $col_word . ' = \'' . implode('\' OR ' . $col_word . ' = \'', $where_any) . '\' )' : '';
   201     $where_any = ( count($where_any) > 0 ) ? '( ' . $col_word . ' = \'' . implode('\' OR ' . $col_word . ' = \'', $where_any) . '\' )' : '';
   202 
   202 
   203     // generate query
   203     // generate query
   204     // using a GROUP BY here ensures that the same word with a different case isn't counted as 2 words - it's all melted back
   204     // using a GROUP BY here ensures that the same word with a different case isn't counted as 2 words - it's all melted back
   205     // into one later in the processing stages
   205     // into one later in the processing stages