function views_handler_relationship::query
Called to implement a relationship in a query.
5 methods override views_handler_relationship::query()
- views_handler_relationship_broken::query in handlers/
views_handler_relationship.inc - Called to implement a relationship in a query.
- views_handler_relationship_entity_reverse::query in modules/
field/ views_handler_relationship_entity_reverse.inc - Called to implement a relationship in a query.
- views_handler_relationship_groupwise_max::query in handlers/
views_handler_relationship_groupwise_max.inc - Called to implement a relationship in a query. This is mostly a copy of our parent's query() except for this bit with the join class.
- views_handler_relationship_node_term_data::query in modules/
taxonomy/ views_handler_relationship_node_term_data.inc - Called to implement a relationship in a query.
- views_handler_relationship_translation::query in modules/
translation/ views_handler_relationship_translation.inc - Called to implement a relationship in a query.
File
-
handlers/
views_handler_relationship.inc, line 109
Class
- views_handler_relationship
- Relationship handler, allows a new version of the primary table to be linked.
Code
public function query() {
// Figure out what base table this relationship brings to the party.
$table_data = views_fetch_data($this->definition['base']);
$base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field'];
$this->ensure_my_table();
$def = $this->definition;
$def['table'] = $this->definition['base'];
$def['field'] = $base_field;
$def['left_table'] = $this->table_alias;
$def['left_field'] = $this->real_field;
if (!empty($this->options['required'])) {
$def['type'] = 'INNER';
}
if (!empty($this->definition['extra'])) {
$def['extra'] = $this->definition['extra'];
}
if (!empty($def['join_handler']) && class_exists($def['join_handler'])) {
$join = new $def['join_handler']();
}
else {
$join = new views_join();
}
$join->definition = $def;
$join->options = $this->options;
$join->construct();
$join->adjusted = TRUE;
// Use a short alias for this.
$alias = $def['table'] . '_' . $this->table;
$this->alias = $this->query
->add_relationship($alias, $join, $this->definition['base'], $this->relationship);
// Add access tags if the base table provide it.
if (empty($this->query->options['disable_sql_rewrite']) && isset($table_data['table']['base']['access query tag'])) {
$access_tag = $table_data['table']['base']['access query tag'];
$this->query
->add_tag($access_tag);
}
}