public function SearchQuery::searchExpression

7.x public SearchQuery::searchExpression($expression, $module)
8.x SearchQuery.php public SearchQuery::searchExpression($expression, $type)

Sets up the search query expression.


$query: A search query string, which can contain options.

$module: The search module. This maps to {search_index}.type in the database.

Return value

The SearchQuery object.


drupal/modules/search/, line 148
Search query extender and helper functions.


Do a query on the full-text search index for a word or words.


public function searchExpression($expression, $module) {
  $this->searchExpression = $expression;
  $this->type = $module;

  // Add a search_* tag. This needs to be added before any preExecute methods
  // for decorated queries are called, as $this->prepared will be set to TRUE
  // and tags added in the execute method will never get used. For example,
  // if $query is extended by 'SearchQuery' then 'PagerDefault', the
  // search-specific tag will be added too late (when preExecute() has
  // already been called from the PagerDefault extender), and as a
  // consequence will not be available to hook_query_alter() implementations,
  // nor will the correct hook_query_TAG_alter() implementations get invoked.
  // See node_search_execute().
  $this->addTag('search_' . $module);

  return $this;