You are here

function comment_service_load_node_comments in Services 6.2

Same name and namespace in other branches
  1. 7 services/comment_service/comment_service.inc \comment_service_load_node_comments()

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.

1 string reference to 'comment_service_load_node_comments'
comment_service_service in services/comment_service/comment_service.module
Implementation of hook_service().

File

services/comment_service/comment_service.inc, line 65
Link commenting functionality to services module.

Code

function comment_service_load_node_comments($nid, $count = 0, $start = 0) {
  $comments = array();
  $limit = (int) $count > 0 ? ' LIMIT ' . (int) $start . ', ' . (int) $count . ' ' : '';
  $result = db_query("SELECT cid FROM {comments} WHERE nid = %d ORDER BY thread DESC" . $limit, $nid);
  while ($comment = db_fetch_array($result)) {
    $comments[] = _comment_load($comment['cid']);
  }
  return $comments;
}