public static function SuggestionStorage::getCount in Autocomplete Search Suggestions 3.0.x
Same name and namespace in other branches
- 8.2 src/SuggestionStorage.php \Drupal\suggestion\SuggestionStorage::getCount()
- 8 src/SuggestionStorage.php \Drupal\suggestion\SuggestionStorage::getCount()
Fetch the row count.
Parameters
string $ngram: The text to search for.
Return value
int The number of rows in the suggestion table.
1 call to SuggestionStorage::getCount()
- SuggestionSearchForm::buildForm in src/
Form/ SuggestionSearchForm.php - The suggestion search form.
File
- src/
SuggestionStorage.php, line 118
Class
- SuggestionStorage
- Database CRUD.
Namespace
Drupal\suggestionCode
public static function getCount($ngram = '') {
if ($ngram) {
return \Drupal::database()
->query("SELECT COUNT(*) FROM {suggestion} WHERE ngram LIKE :ngram", [
':ngram' => $ngram,
])
->fetchField();
}
return \Drupal::database()
->query("SELECT COUNT(*) FROM {suggestion}")
->fetchField();
}