function views_handler_join_nodehierarchy_ancestor::build_join in Node Hierarchy 7.2
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
- includes/
views/ nodehierarchy.views.inc, line 130 - Implementations of Views 2 Hooks for nodehierarchy_views module
Class
Code
function build_join($select_query, $table, $view_query) {
$left = $view_query
->get_table_info($this->left_table);
$right_table = "{" . $this->table . "}";
$on = array();
for ($i = 1; $i < MENU_MAX_DEPTH; $i++) {
$on[] = "{$left['alias']}.p{$i} = {$table['alias']}.mlid";
}
$select_query
->addJoin($this->type, $right_table, $table['alias'], '(' . implode(' OR ', $on) . ") AND {$left['alias']}.mlid != {$table['alias']}.mlid", array());
}