You are here

function _search_parse_query in Drupal 4

Same name and namespace in other branches
  1. 5 modules/search/search.module \_search_parse_query()
  2. 6 modules/search/search.module \_search_parse_query()

Helper function for search_parse_query();

1 call to _search_parse_query()
search_parse_query in modules/search.module
Parse a search query into SQL conditions.

File

modules/search.module, line 746
Enables site-wide keyword searching.

Code

function _search_parse_query(&$word, &$scores, $not = false) {
  $count = 0;

  // Determine the scorewords of this word/phrase
  if (!$not) {
    $split = explode(' ', $word);
    foreach ($split as $s) {
      $num = is_numeric($s);
      if ($num || drupal_strlen($s) >= variable_get('minimum_word_size', 3)) {
        $s = $num ? (int) ltrim($s, '-0') : $s;
        if (!isset($scores[$s])) {
          $scores[$s] = $s;
          $count++;
        }
      }
    }
  }

  // Return matching snippet and number of added words
  return array(
    "d.data " . ($not ? 'NOT ' : '') . "LIKE '%% %s %%'",
    $count,
  );
}