You are here

public static function SuggestionStorage::getTitles in Autocomplete Search Suggestions 7

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 218
CRUD methods for the suggestion module.

Class

SuggestionStorage
Database CRUD.

Code

public static function getTitles($nid = 0, $limit = NULL) {
  $args = array(
    ':nid' => (int) $nid,
    ':types' => SuggestionHelper::types(),
  );
  if (!count($args[':types'])) {
    return array();
  }
  $stmt = "\n      SELECT\n        nid,\n        title\n      FROM\n        {node}\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();
}