My oh my, how times have changed. Here is how you can get all the comments for a node in Drupal 7 (much different from D6):
$nid = 2012;
$query = db_select("comment", "c");
$query
->condition("c.nid", $nid)
->condition("fdcb.entity_type", "comment")
->condition("c.status", 1)
->fields("c",
array(
"cid",
"pid",
"nid",
"uid",
"subject",
"hostname",
"created",
"changed",
"status",
"thread",
"name",
"mail",
"homepage",
"language"
)
)
->fields('fdcb',
array(
"entity_type",
"bundle",
"deleted",
"entity_id",
"revision_id",
"language",
"delta",
"comment_body_value",
"comment_body_format"
)
)
->orderBy('c.created', 'asc')
->innerJoin('field_data_comment_body', 'fdcb', 'fdcb.entity_id = c.cid');
$result = $query->execute();
return $result->fetchAll();
Add new comment