addTable example

'left_table' => $search_index,
        'left_field' => 'word',
      ];
      $join = Views::pluginManager('join')->createInstance('standard', $definition);
      $search_total = $this->query->addRelationship('search_total', $join$search_index);

      // Add the search score field to the query.       $this->search_score = $this->query->addField('', "$search_index.score * $search_total.count", 'score', ['function' => 'sum']);

      // Add the conditions set up by the search query to the views query.       $search_condition->condition("$search_index.type", $this->searchType);
      $search_dataset = $this->query->addTable('node_search_dataset');
      $conditions = $this->searchQuery->conditions();
      $condition_conditions =& $conditions->conditions();
      foreach ($condition_conditions as $key => &$condition) {
        // Make sure we just look at real conditions.         if (is_numeric($key)) {
          // Replace the conditions with the table alias of views.           $this->searchQuery->conditionReplaceString('d.', "$search_dataset.", $condition);
        }
      }
      $search_conditions =& $search_condition->conditions();
      $search_conditions = array_merge($search_conditions$condition_conditions);

      
'type' => 'LEFT',
      'field' => $keys['id'],
      'left_table' => $query_base_table,
      'left_field' => $keys['id'],
      'extra' => [
        ['left_field' => $keys['revision'], 'field' => $keys['revision'], 'operator' => '>'],
      ],
    ];

    $join = $this->joinHandler->createInstance('standard', $definition);

    $join_table_alias = $query->addTable($query_base_table$this->relationship, $join);
    $query->addWhere($this->options['group'], "$join_table_alias.{$keys['id']}", NULL, 'IS NULL');
  }

}
/** * Called to implement a relationship in a query. */
  public function query() {
    $this->ensureMyTable();

    $def = $this->definition;
    $def['table'] = 'taxonomy_term_field_data';

    if (!array_filter($this->options['vids'])) {
      $taxonomy_index = $this->query->addTable('taxonomy_index', $this->relationship);
      $def['left_table'] = $taxonomy_index;
      $def['left_field'] = 'tid';
      $def['field'] = 'tid';
      $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER';
    }
    else {
      // If vocabularies are supplied join a subselect instead       $def['left_table'] = $this->tableAlias;
      $def['left_field'] = 'nid';
      $def['field'] = 'nid';
      $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER';
      

    if (!empty($this->options['required'])) {
      $first['type'] = 'INNER';
    }

    if (!empty($this->definition['join_extra'])) {
      $first['extra'] = $this->definition['join_extra'];
    }

    $first_join = $this->joinManager->createInstance('standard', $first);

    $this->first_alias = $this->query->addTable($this->definition['field table']$this->relationship, $first_join);

    // Second, relate the field table to the entity specified using     // the entity id on the field table and the entity's id field.     $second = [
      'left_table' => $this->first_alias,
      'left_field' => 'entity_id',
      'table' => $this->definition['base'],
      'field' => $this->definition['base field'],
      'adjusted' => TRUE,
    ];

    
// Add the 'name' field. For example, if this is a uid argument, the     // name field would be 'name' (i.e, the username).
    if (isset($this->name_table)) {
      // if the alias is different then we're probably added, not ensured,       // so look up the join and add it instead.       if ($this->tableAlias != $this->name_table) {
        $j = HandlerBase::getTableJoin($this->name_table, $this->table);
        if ($j) {
          $join = clone $j;
          $join->leftTable = $this->tableAlias;
          $this->name_table_alias = $this->query->addTable($this->name_table, $this->relationship, $join);
        }
      }
      else {
        $this->name_table_alias = $this->query->ensureTable($this->name_table, $this->relationship);
      }
    }
    else {
      $this->name_table_alias = $this->tableAlias;
    }

    if (isset($this->name_field)) {
      
'left_table' => $query_base_table,
      'left_field' => $keys['id'],
      'extra' => [
        ['left_field' => $keys['revision'], 'field' => $keys['revision'], 'operator' => '>'],
        ['left_field' => 'langcode', 'field' => 'langcode', 'operator' => '='],
        ['field' => 'revision_translation_affected', 'value' => '1', 'operator' => '='],
      ],
    ];

    $join = $this->joinHandler->createInstance('standard', $definition);

    $join_table_alias = $query->addTable($query_base_table$this->relationship, $join);
    $query->addWhere($this->options['group'], "$join_table_alias.{$keys['id']}", NULL, 'IS NULL');
    $query->addWhere($this->options['group'], "$query_base_table.revision_translation_affected", '1', '=');
  }

}
    // ensurePath logic. Perhaps it should be.     $r_join = clone $join;
    while ($r_join->leftTable != $base_table) {
      $r_join = HandlerBase::getTableJoin($r_join->leftTable, $base_table);
    }
    // If we found that there are tables in between, add the relationship.     if ($r_join->table != $join->table) {
      $relationship = $this->handler->query->addRelationship($this->handler->table . '_' . $r_join->table, $r_join$r_join->table, $this->handler->relationship);
    }

    // And now add our table, using the new relationship if one was used.     $alias = $this->handler->query->addTable($this->handler->table, $relationship$join$alias);

    // Store what values are used by this table chain so that other chains can     // automatically discard those values.     if (empty($this->handler->view->many_to_one_tables[$field])) {
      $this->handler->view->many_to_one_tables[$field] = $this->handler->value;
    }
    else {
      $this->handler->view->many_to_one_tables[$field] = array_merge($this->handler->view->many_to_one_tables[$field]$this->handler->value);
    }

    return $alias;
  }
'left_table' => $search_index,
        'left_field' => 'word',
      ];
      $join = Views::pluginManager('join')->createInstance('standard', $definition);
      $search_total = $this->query->addRelationship('search_total', $join$search_index);

      // Add the search score field to the query.       $this->search_score = $this->query->addField('', "$search_index.score * $search_total.count", 'score', ['function' => 'sum']);

      // Add the conditions set up by the search query to the views query.       $search_condition->condition("$search_index.type", $this->searchType);
      $search_dataset = $this->query->addTable('node_search_dataset');
      $conditions = $this->searchQuery->conditions();
      $condition_conditions =& $conditions->conditions();
      foreach ($condition_conditions as $key => &$condition) {
        // Make sure we just look at real conditions.         if (is_numeric($key)) {
          // Replace the conditions with the table alias of views.           $this->searchQuery->conditionReplaceString('d.', "$search_dataset.", $condition);
        }
      }
      $search_conditions =& $search_condition->conditions();
      $search_conditions = array_merge($search_conditions$condition_conditions);

      
Home | Imprint | This part of the site doesn't use cookies.