Join handler for relationships that join with a subquery as the left field.
eg:
LEFT JOIN node node_term_data ON ([YOUR SUBQUERY HERE]) = node_term_data.nid
join definition
same as views_join class above, except:
left_query : The subquery to use in the left side of the join clause.
Hierarchy
Expanded class hierarchy of views_join_subquery
Related topics
1 string reference to 'views_join_subquery'
File
core/modules/views/includes/handlers.inc , line 1168
Defines the various handler objects to help build and display views.
View source class views_join_subquery extends views_join {
function construct ($table = NULL , $left_table = NULL , $left_field = NULL , $field = NULL , $extra = array (), $type = 'LEFT' ) {
parent ::construct ($table , $left_table , $left_field , $field , $extra , $type );
$this ->left_query = $this ->definition ['left_query' ];
}
public function build_join ($select_query , $table , $view_query ) {
if (empty ($this ->definition ['table formula' ])) {
$right_table = "{" . $this ->table . "}" ;
}
else {
$right_table = $this ->definition ['table formula' ];
}
$condition = "($this->left_query) = $table[alias].$this->field" ;
$arguments = array ();
if (isset ($this ->extra )) {
if (!is_array ($this ->extra )) {
$this ->extra = array ($this ->extra );
}
$extras = array ();
foreach ($this ->extra as $info ) {
if (is_array ($info )) {
$extra = '' ;
$join_table = '' ;
if (!array_key_exists ('table ' , $info )) {
$join_table = $table ['alias' ] . '.' ;
}
elseif (isset ($info ['table ' ])) {
$join_table = $info ['table ' ] . '.' ;
}
$placeholder = ':views_join_condition_' . $select_query ->nextPlaceholder ();
if (is_array ($info ['value' ])) {
$operator = !empty ($info ['operator' ]) ? $info ['operator' ] : 'IN' ;
if (count ($info ['value' ]) == 1 ) {
$info ['value' ] = array_shift ($info ['value' ]);
$operator = $operator == 'NOT IN' ? '!=' : '=' ;
}
}
else {
$operator = !empty ($info ['operator' ]) ? $info ['operator' ] : '=' ;
}
$extras [] = "$join_table$info[field] $operator $placeholder" ;
$arguments [$placeholder ] = $info ['value' ];
}
elseif (is_string ($info )) {
$extras [] = $info ;
}
}
if ($extras ) {
if (count ($extras ) == 1 ) {
$condition .= ' AND (' . array_shift ($extras ) . ')' ;
}
else {
$condition .= ' AND (' . implode (' ' . $this ->extra_type . ' ' , $extras ) . ')' ;
}
}
}
$select_query ->addJoin ($this ->type , $right_table , $table ['alias' ], $condition , $arguments );
}
}
Members