You are here

function _node_resource_load_node_comments in Services 6.3

Same name and namespace in other branches
  1. 7.3 resources/node_resource.inc \_node_resource_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.

2 string references to '_node_resource_load_node_comments'
hook_services_resources in ./services.services.api.php
Implementation of hook_services_resources(). Defines function signatures for resources available to services.
_node_resource_definition in resources/node_resource.inc
@file This file will define the resources for dealing directly with nodes

File

resources/node_resource.inc, line 200
This file will define the resources for dealing directly with nodes

Code

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