function CommentStatistics::read

Same name and namespace in other branches
  1. 11.x core/modules/comment/src/CommentStatistics.php \Drupal\comment\CommentStatistics::read()
  2. 10 core/modules/comment/src/CommentStatistics.php \Drupal\comment\CommentStatistics::read()
  3. 8.9.x core/modules/comment/src/CommentStatistics.php \Drupal\comment\CommentStatistics::read()

File

core/modules/comment/src/CommentStatistics.php, line 76

Class

CommentStatistics

Namespace

Drupal\comment

Code

public function read($entities, $entity_type, $accurate = TRUE) {
  $connection = $accurate ? $this->database : $this->databaseReplica;
  $stats = $connection->select('comment_entity_statistics', 'ces')
    ->fields('ces')
    ->condition('ces.entity_id', array_keys($entities), 'IN')
    ->condition('ces.entity_type', $entity_type)
    ->execute();
  $statistics_records = [];
  while ($entry = $stats->fetchObject()) {
    $statistics_records[] = $entry;
  }
  return $statistics_records;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.