Join handler for relationships that join with a subquery as the left field. More...
Public Member Functions | |
construct ($table=NULL, $left_table=NULL, $left_field=NULL, $field=NULL, $extra=array(), $type= 'LEFT') | |
Construct the views_join object. | |
build_join ($select_query, $table, $view_query) | |
Build the SQL for the join this object represents. | |
Public Attributes | |
$table = NULL | |
$left_table = NULL | |
$left_field = NULL | |
$field = NULL | |
$extra = NULL | |
$type = NULL | |
$definition = array() |
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:
Definition at line 1587 of file handlers.inc.
views_join_subquery::build_join | ( | $ | select_query, | |
$ | table, | |||
$ | view_query | |||
) |
Build the SQL for the join this object represents.
$select_query | An implementation of SelectQueryInterface. | |
$table | The base table to join. | |
$view_query | The source query, implementation of views_plugin_query. |
Reimplemented from views_join.
Definition at line 1605 of file handlers.inc.
{ if (empty($this->definition['table formula'])) { $right_table = "{" . $this->table . "}"; } else { $right_table = $this->definition['table formula']; } // Add our join condition, using a subquery on the left instead of a field. $condition = "($this->left_query) = $table[alias].$this->field"; $arguments = array(); // Tack on the extra. // This is just copied verbatim from the parent class, which itself has a bug: http://drupal.org/node/1118100 if (isset($this->extra)) { if (is_array($this->extra)) { $extras = array(); foreach ($this->extra as $info) { $extra = ''; // Figure out the table name. Remember, only use aliases provided // if at all possible. $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'; // Transform from IN() notation to = notation if just one value. 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']; } if ($extras) { if (count($extras) == 1) { $condition .= ' AND ' . array_shift($extras); } else { $condition .= ' AND (' . implode(' ' . $this->extra_type . ' ', $extras) . ')'; } } } elseif ($this->extra && is_string($this->extra)) { $condition .= " AND ($this->extra)"; } } $select_query->addJoin($this->type, $right_table, $table['alias'], $condition, $arguments); }
views_join_subquery::construct | ( | $ | table = NULL , |
|
$ | left_table = NULL , |
|||
$ | left_field = NULL , |
|||
$ | field = NULL , |
|||
$ | extra = array() , |
|||
$ | type = 'LEFT' | |||
) |
Construct the views_join object.
Reimplemented from views_join.
Definition at line 1588 of file handlers.inc.
{ parent::construct($table, $left_table, $left_field, $field, $extra, $type); $this->left_query = $this->definition['left_query']; }