You are here

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

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

Calculate the suggestion's bitmap.

Parameters

string $ngram: The text to index.

int $src: The bits to OR with the current bitmap.

Return value

int The new bitmap value.

2 calls to SuggestionStorage::getBitmap()
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 91

Class

SuggestionStorage
Database CRUD.

Namespace

Drupal\suggestion

Code

public static function getBitmap($ngram = '', $src = self::CONTENT_BIT) {
  $args = [
    ':ngram' => $ngram,
    ':src' => (int) $src,
  ];
  return \Drupal::database()
    ->query("SELECT IFNULL(SUM(src), 0) | :src FROM {suggestion} WHERE ngram = :ngram", $args)
    ->fetchField();
}