You are here

protected function EntityFieldQuery::addFieldJoin in RESTful 7.2

Adds a join to the field table with the appropriate join type.

Parameters

SelectQuery $select_query: The select query to modify.

string $field_name: The name of the field to join.

string $table: The table against which to join.

string $alias: The alias for the table. In most cases this should be the first letter of the table, or the first letter of each "word" in the table.

string $condition: The condition on which to join this table. If the join requires values, this clause should use a named placeholder and the value or values to insert should be passed in the 4th parameter. For the first table joined on a query, this value is ignored as the first table is taken as the base table. The token %alias can be used in this string to be replaced with the actual alias. This is useful when $alias is modified by the database system, for example, when joining the same table more than once.

array $arguments: An array of arguments to replace into the $condition of this join.

Return value

string The unique alias that was assigned for this table.

Overrides EntityFieldQuery::addFieldJoin

1 call to EntityFieldQuery::addFieldJoin()
EntityFieldQuery::fieldStorageQuery in src/Util/EntityFieldQuery.php
Copies field_sql_storage_field_storage_query() using left joins some times.
1 method overrides EntityFieldQuery::addFieldJoin()
EntityFieldQuery::addFieldJoin in src/Util/EntityFieldQuery.php
Adds a join to the field table with the appropriate join type.

File

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

Class

EntityFieldQuery

Namespace

Drupal\restful\Util

Code

protected function addFieldJoin(SelectQuery $select_query, $field_name, $table, $alias = NULL, $condition = NULL, $arguments = array()) {

  // Find if we need a left or inner join by inspecting the field conditions.
  $type = 'INNER';
  foreach ($this->fieldConditions as $field_condition) {
    if ($field_condition['field']['field_name'] == $field_name) {
      $type = in_array($field_condition['operator'], static::$leftJoinOperators) ? 'LEFT' : 'INNER';
      break;
    }
  }
  return $select_query
    ->addJoin($type, $table, $alias, $condition, $arguments);
}