You are here

protected static function EntityFieldQuery::aliasJoinTable in RESTful 7.2

Helper function tha checks if the select query already has a join.

Parameters

string $table_name: The name of the table.

SelectQuery $query: The query.

Return value

string The table alias.

Overrides EntityFieldQuery::aliasJoinTable

1 method overrides EntityFieldQuery::aliasJoinTable()
EntityFieldQuery::aliasJoinTable in src/Util/EntityFieldQuery.php
Helper function tha checks if the select query already has a join.

File

src/Util/EntityFieldQuery.php, line 192
Contains \Drupal\restful\Util\EntityFieldQuery.

Class

EntityFieldQuery

Namespace

Drupal\restful\Util

Code

protected static function aliasJoinTable($table_name, SelectQuery $query) {
  foreach ($query
    ->getTables() as $table_info) {
    if ($table_info['alias'] == $table_name) {
      $matches = array();
      preg_match('/.*_(\\d+)$/', $table_name, $matches);
      $num = empty($matches[1]) ? -1 : $matches[1];
      return static::aliasJoinTable($table_name . '_' . ($num + 1), $query);
    }
  }
  return $table_name;
}