You are here

public static function SuggestionStorage::search in Autocomplete Search Suggestions 7

Search suggestions.

Parameters

string $ngram: The requested ngram.

int $start: The starting offset.

int $limit: The query limit.

Return value

array An array of suggestion objects.

1 call to SuggestionStorage::search()
suggestion_admin_search_form in ./suggestion.admin.inc
Menu callback to index suggestions.

File

src/SuggestionStorage.php, line 273
CRUD methods for the suggestion module.

Class

SuggestionStorage
Database CRUD.

Code

public static function search($ngram, $start = NULL, $limit = 100) {
  $args = array(
    ':ngram' => $ngram,
  );
  if (is_numeric($start) && intval($limit)) {
    return db_query_range("SELECT * FROM {suggestion} WHERE ngram LIKE :ngram ORDER BY ngram ASC", $start, $limit, $args)
      ->fetchAll();
  }
  return db_query("SELECT * FROM {suggestion} WHERE ngram LIKE :ngram ORDER BY ngram ASC", $args)
    ->fetchAll();
}