You are here

function _views_query::ensure_path in Views (for Drupal 7) 5

2 calls to _views_query::ensure_path()
_views_query::add_table in ./views_query.inc
_views_query::ensure_table in ./views_query.inc

File

./views_query.inc, line 511

Class

_views_query

Code

function ensure_path($table, $traced = array(), $add = array()) {
  if ($table == $this->primary_table) {
    return true;
  }
  $table_data = _views_get_tables();
  $left_table = $table_data[$table]['join']['left']['table'];

  // Does it end at our views_get_title table?
  if ($left_table == $this->primary_table) {

    // We are done! Add our tables and unwind.
    foreach (array_reverse($add) as $table) {
      $this
        ->queue_table($table);
    }
    return true;
  }

  // Have we been this way?
  if (isset($traced[$left_table])) {

    // we looped. Broked.
    return false;
  }

  // Do we have to add this table?
  if (!isset($this->tables[$left_table])) {
    $add[] = $left_table;
  }

  // Keep looking.
  $traced[$left_table] = 1;
  return $this
    ->ensure_path($left_table, $traced, $add);
}