You are here

public static function SuggestionStorage::getAllSuggestions in Autocomplete Search Suggestions 8.2

Same name and namespace in other branches
  1. 8 src/SuggestionStorage.php \Drupal\suggestion\SuggestionStorage::getAllSuggestions()
  2. 3.0.x src/SuggestionStorage.php \Drupal\suggestion\SuggestionStorage::getAllSuggestions()

Fetch all the suggestions.

Parameters

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::getAllSuggestions()
SuggestionSearchForm::buildForm in src/Form/SuggestionSearchForm.php
The suggestion search form.

File

src/SuggestionStorage.php, line 39

Class

SuggestionStorage
Database CRUD.

Namespace

Drupal\suggestion

Code

public static function getAllSuggestions($langcode = '', $start = NULL, $limit = 100) {
  if (is_numeric($start) && intval($limit)) {
    return \Drupal::database()
      ->queryRange("SELECT * FROM {suggestion} WHERE langcode = :langcode ORDER BY ngram ASC", $start, $limit, [
      ':langcode' => $langcode,
    ])
      ->fetchAll();
  }
  return \Drupal::database()
    ->query("SELECT * FROM {suggestion} WHERE langcode = :langcode ORDER BY ngram ASC", [
    ':langcode' => $langcode,
  ])
    ->fetchAll();
}