You are here

public function Table::link in Data 8

Link this table to another table. Linking a table to another one is to define how data in these tables should be joined to each other.

There can be more than one link to the left of a table. However, for views integration, only the first join created will be used.

@todo: Get rid of link() language, use setJoin()/removeJoin() instead.

File

src/Table.php, line 548

Class

Table
Manages data access and manipulation for a single data table. Use data_create_table() or data_get_table() to instantiate an object from this class.

Namespace

Drupal\data

Code

public function link($left_table, $left_field, $field = NULL, $inner_join = TRUE) {
  if ($field == NULL) {
    $field = $left_table;
  }
  $this->meta['join'][$left_table] = array(
    'left_field' => $left_field,
    'field' => $field,
    'inner_join' => $inner_join,
  );
  $this
    ->update(array(
    'meta' => $this->meta,
  ));
}