Same name and namespace in other branches
  1. 6.x-3.x plugins/views_plugin_query_default.inc \views_plugin_query_default::add_table()

Add a table to the query, ensuring the path exists.

This function will test to ensure that the path back to the primary table is valid and exists; if you do not wish for this testing to occur, use $query->queue_table() instead.

Parameters

string $table: The name of the table to add. It needs to exist in the global table array.

string $relationship: An alias of a table; if this is set, the path back to this table will be tested prior to adding the table, making sure that all intermediary tables exist and are properly aliased. If set to NULL the path to the primary table will be ensured. If the path cannot be made, the table will NOT be added.

views_join $join: In some join configurations this table may actually join back through a different method; this is most likely to be used when tracing a hierarchy path. (node->parent->parent2->parent3). This parameter will specify how this table joins if it is not the default.

string $alias: A specific alias to use, rather than the default alias.

Return value

string The alias of the table; this alias can be used to access information about the table and should always be used to refer to the table when adding parts to the query. Or FALSE if the table was not able to be added.

File

plugins/views_plugin_query_default.inc, line 425
Definition of views_plugin_query_default.

Class

views_plugin_query_default
Object used to create a SELECT query.

Code

public function add_table($table, $relationship = NULL, $join = NULL, $alias = NULL) {
  if (!$this
    ->ensure_path($table, $relationship, $join)) {
    return FALSE;
  }
  if ($join && $relationship) {
    $join = $this
      ->adjust_join($join, $relationship);
  }
  return $this
    ->queue_table($table, $relationship, $join, $alias);
}