_node_resource_load_node_comments

  1. services
    1. 7.3
    2. 6.3
Versions
6.3 _node_resource_load_node_comments($nid, $count, $start)
7.3 _node_resource_load_node_comments($nid, $count = 0, $start = 0)

Returns the comments of a specified node.

Parameters

$nid Unique identifier for the node.

$count Number of comments to return.

$start Which comment to start with. If present, $start and $count are used together to create a LIMIT clause for selecting comments. This could be used to do paging.

Return value

An array of comment objects.

Code

resources/node_resource.inc, line 512

<?php
function _node_resource_load_node_comments($nid, $count = 0, $start = 0) {
  $query = db_select('comment', 'c');
  $query->innerJoin('node', 'n', 'n.nid = c.nid');
  $query->addTag('node_access');
  $query->fields('c', array('cid'))
    ->condition('c.nid', $nid);

  if ($count) {
    $query->range($start, $count);
  }

  $result = $query->execute()
    ->fetchAll();

  foreach ($result as $record) {
    $cids[] = $record->cid;
  }

  return !empty($cids) ? comment_load_multiple($cids) : array();
}
?>