protected function CommentController::buildQuery

protected CommentController::buildQuery($ids, $conditions = array(), $revision_id = FALSE)

Builds the query to load the entity.

This has full revision support. For entities requiring special queries, the class can be extended, and the default query can be constructed by calling parent::buildQuery(). This is usually necessary when the object being loaded needs to be augmented with additional data from another table, such as loading node type into comments or vocabulary machine name into terms, however it can also support $conditions on different tables. See CommentController::buildQuery() or TaxonomyTermController::buildQuery() for examples.

Parameters

$ids: An array of entity IDs, or FALSE to load all entities.

$conditions: An array of conditions. Keys are field names on the entity's base table. Values will be compared for equality. All the comparisons will be ANDed together. This parameter is deprecated; use an EntityFieldQuery instead.

$revision_id: The ID of the revision to load, or FALSE if this query is asking for the most current revision(s).

Return value

SelectQuery A SelectQuery object for loading the entity.

Overrides DrupalDefaultEntityController::buildQuery

File

modules/comment/comment.module, line 1700
Enables users to comment on published content.

Class

CommentController
Controller class for comments.

Code

protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
  $query = parent::buildQuery($ids, $conditions, $revision_id);
  // Specify additional fields from the user and node tables.
  $query->innerJoin('node', 'n', 'base.nid = n.nid');
  $query->addField('n', 'type', 'node_type');
  $query->innerJoin('users', 'u', 'base.uid = u.uid');
  $query->addField('u', 'name', 'registered_name');
  $query->fields('u', array('uid', 'signature', 'signature_format', 'picture'));
  return $query;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!comment!comment.module/function/CommentController::buildQuery/7.x