function views_join_term_edge::build_join in Taxonomy Edge 7.2
Same name and namespace in other branches
- 8 views_taxonomy_edge/handlers/views_join_term_edge.inc \views_join_term_edge::build_join()
- 7 views_taxonomy_edge/handlers/views_join_term_edge.inc \views_join_term_edge::build_join()
Build the SQL for the join this object represents.
When possible, try to use table alias instead of table names.
Parameters
SelectQueryInterface $select_query: An Implements SelectQueryInterface.
string $table: The base table to join.
views_plugin_query $view_query: The source query, Implements views_plugin_query.
Overrides views_join::build_join
File
- views_taxonomy_edge/
handlers/ views_join_term_edge.inc, line 6
Class
- views_join_term_edge
- @file
Code
function build_join($select_query, $table, $view_query) {
$found = FALSE;
// If there's a condition on parent, then let it be unless it's blank.
// If it's blank we set it to the root pid.
foreach ($view_query->where as $data) {
foreach ($data['conditions'] as $condition) {
if ($condition['field'] == $table['alias'] . '.parent') {
if ($condition['value'] == '') {
$condition['value'] = taxonomy_term_edge_get_root_pid();
}
else {
$found = TRUE;
break;
}
}
}
}
// If no condition on parent was found, add the root pid as a condition.
if (!$found) {
$this->extra = array(
array(
'field' => 'parent',
'value' => taxonomy_edge_get_root_pid(),
),
);
}
parent::build_join($select_query, $table, $view_query);
}