public static function SuggestionStorage::getTitles in Autocomplete Search Suggestions 8
Same name and namespace in other branches
- 8.2 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 215 
Class
- SuggestionStorage
- Database CRUD.
Namespace
Drupal\suggestionCode
public static function getTitles($nid = 0, $limit = NULL) {
  $args = [
    ':nid' => (int) $nid,
    ':types[]' => SuggestionHelper::types(),
  ];
  if (!count($args[':types[]'])) {
    return [];
  }
  $stmt = "\n      SELECT\n        nid,\n        title\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    ";
  if (is_numeric($limit)) {
    return db_query_range($stmt, 0, $limit, $args)
      ->fetchAllKeyed();
  }
  return db_query($stmt, $args)
    ->fetchAllKeyed();
}