function views_handler_relationship::query
Same name in other branches
- 7.x-3.x handlers/views_handler_relationship.inc \views_handler_relationship::query()
Called to implement a relationship in a query.
Overrides views_handler::query
3 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_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 105
Class
- views_handler_relationship
- Simple relationship handler that allows a new version of the primary table to be linked in.
Code
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'], FALSE)) {
$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);
}