public static function SuggestionStorage::getTitles in Autocomplete Search Suggestions 8.2
Same name and namespace in other branches
- 8 src/SuggestionStorage.php \Drupal\suggestion\SuggestionStorage::getTitles()
- 3.0.x src/SuggestionStorage.php \Drupal\suggestion\SuggestionStorage::getTitles()
Fetch an array of node titles.
Parameters
int $nid: The Node ID of the last node batched.
int $limit: The query limit.
Return value
array A node ID to title hash.
1 call to SuggestionStorage::getTitles()
- SuggestionHelper::index in src/
SuggestionHelper.php - Create a suggestion index from content titles.
File
- src/
SuggestionStorage.php, line 235
Class
- SuggestionStorage
- Database CRUD.
Namespace
Drupal\suggestionCode
public static function getTitles($nid = 0, $limit = PHP_INT_MAX) {
$args = [
':nid' => (int) $nid,
':types[]' => SuggestionHelper::types(),
];
$stmt = "\n SELECT\n nid,\n title,\n langcode\n FROM\n {node_field_data}\n WHERE\n status = 1\n AND nid > :nid\n AND type IN (:types[])\n ORDER BY\n nid ASC\n ";
return count($args[':types[]']) ? \Drupal::database()
->queryRange($stmt, 0, $limit, $args)
->fetchAll() : [];
}