public static function SuggestionStorage::search in Autocomplete Search Suggestions 8.2
Same name and namespace in other branches
- 8 src/SuggestionStorage.php \Drupal\suggestion\SuggestionStorage::search()
- 3.0.x src/SuggestionStorage.php \Drupal\suggestion\SuggestionStorage::search()
Search suggestions.
Parameters
string $ngram: The requested ngram.
string $langcode: The language code.
int $start: The starting offset.
int $limit: The query limit.
Return value
array An array of suggestion objects.
1 call to SuggestionStorage::search()
- SuggestionSearchForm::buildForm in src/
Form/ SuggestionSearchForm.php - The suggestion search form.
File
- src/
SuggestionStorage.php, line 300
Class
- SuggestionStorage
- Database CRUD.
Namespace
Drupal\suggestionCode
public static function search($ngram, $langcode, $start = NULL, $limit = 100) {
$args = [
':langcode' => $langcode,
':ngram' => $ngram,
];
if (is_numeric($start) && intval($limit)) {
return \Drupal::database()
->queryRange("SELECT * FROM {suggestion} WHERE langcode = :langcode AND ngram LIKE :ngram ORDER BY ngram ASC", $start, $limit, $args)
->fetchAll();
}
return \Drupal::database()
->query("SELECT * FROM {suggestion} WHERE langcode = :langcode AND ngram LIKE :ngram ORDER BY ngram ASC", $args)
->fetchAll();
}