You are here

function views_get_table_join in Views (for Drupal 7) 6.2

Same name and namespace in other branches
  1. 6.3 includes/handlers.inc \views_get_table_join()
  2. 7.3 includes/handlers.inc \views_get_table_join()

Fetch a handler to join one table to a primary table from the data cache

4 calls to views_get_table_join()
views_handler::get_join in includes/handlers.inc
Get the join object that should be used for this handler.
views_handler_argument::summary_name_field in handlers/views_handler_argument.inc
Add the name field, which is the field displayed in summary queries. This is often used when the argument is numeric.
views_many_to_one_helper::add_table in includes/handlers.inc
Add a table to the query.
views_query::get_join_data in includes/query.inc
Retrieve join data from the larger join data cache.

File

includes/handlers.inc, line 168
handlers.inc Defines the various handler objects to help build and display views.

Code

function views_get_table_join($table, $base_table) {
  $data = views_fetch_data($table);
  if (isset($data['table']['join'][$base_table])) {
    $h = $data['table']['join'][$base_table];
    if (!empty($h['handler']) && class_exists($h['handler'])) {
      $handler = new $h['handler']();
    }
    else {
      $handler = new views_join();
    }

    // Fill in some easy defaults
    $handler->definition = $h;
    if (empty($handler->definition['table'])) {
      $handler->definition['table'] = $table;
    }

    // If this is empty, it's a direct link.
    if (empty($handler->definition['left_table'])) {
      $handler->definition['left_table'] = $base_table;
    }
    if (isset($h['arguments'])) {
      call_user_func_array(array(
        &$handler,
        'construct',
      ), $h['arguments']);
    }
    else {
      $handler
        ->construct();
    }
    return $handler;
  }

  // DEBUG -- identify missing handlers
  vpr("Missing join: {$table} {$base_table}");
}