You are here

public static function SuggestionStorage::getNgramQty in Autocomplete Search Suggestions 3.0.x

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

Fetch the quantity for the supplied ngram.

Parameters

string $ngram: The ngram value.

Return value

int The qty value for the supplied ngram.

2 calls to SuggestionStorage::getNgramQty()
SuggestionHelper::insert in src/SuggestionHelper.php
Add a suggestion.
suggestion_surfer_submit in ./suggestion.module
Custom submit function to add surfer suggestions.

File

src/SuggestionStorage.php, line 144

Class

SuggestionStorage
Database CRUD.

Namespace

Drupal\suggestion

Code

public static function getNgramQty($ngram = '') {
  return \Drupal::database()
    ->query("SELECT IFNULL(SUM(qty), 0) FROM {suggestion} WHERE ngram = :ngram", [
    ':ngram' => $ngram,
  ])
    ->fetchField();
}