Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home1/tylerfra/public_html/includes/common.inc).

Drupal 7 Retrieve Node Comments with Database API

Category: 

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();