NodeController::buildQuery

protected function NodeController::buildQuery

protected NodeController::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/node/node.module, line 4179
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

Class

NodeController
Controller class for nodes.

Code

protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
  // Ensure that uid is taken from the {node} table,
  // alias timestamp to revision_timestamp and add revision_uid.
  $query = parent::buildQuery($ids, $conditions, $revision_id);
  $fields = &$query->getFields();
  unset($fields['timestamp']);
  $query->addField('revision', 'timestamp', 'revision_timestamp');
  $fields['uid']['table'] = 'base';
  $query->addField('revision', 'uid', 'revision_uid');
  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!node!node.module/function/NodeController::buildQuery/7.x

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部