You are here

public static function Condition::translateCondition in Zircon Profile 8

Same name in this branch
  1. 8 core/lib/Drupal/Core/Entity/Query/Sql/Condition.php \Drupal\Core\Entity\Query\Sql\Condition::translateCondition()
  2. 8 core/lib/Drupal/Core/Entity/Query/Sql/pgsql/Condition.php \Drupal\Core\Entity\Query\Sql\pgsql\Condition::translateCondition()
Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Entity/Query/Sql/pgsql/Condition.php \Drupal\Core\Entity\Query\Sql\pgsql\Condition::translateCondition()

Translates the string operators to SQL equivalents.

Parameters

array $condition: The condition array.

\Drupal\Core\Database\Query\SelectInterface $sql_query: Select query instance.

bool|null $case_sensitive: If the condition should be case sensitive or not, NULL if the field does not define it.

Overrides Condition::translateCondition

See also

\Drupal\Core\Database\Query\ConditionInterface::condition()

File

core/lib/Drupal/Core/Entity/Query/Sql/pgsql/Condition.php, line 21
Contains \Drupal\Core\Entity\Query\Sql\pgsql\Condition.

Class

Condition
Implements entity query conditions for PostgreSQL databases.

Namespace

Drupal\Core\Entity\Query\Sql\pgsql

Code

public static function translateCondition(&$condition, SelectInterface $sql_query, $case_sensitive) {
  if (is_array($condition['value']) && $case_sensitive === FALSE) {
    $condition['where'] = 'LOWER(' . $sql_query
      ->escapeField($condition['real_field']) . ') ' . $condition['operator'] . ' (';
    $condition['where_args'] = [];
    $n = 1;

    // Only use the array values in case an associative array is passed as an
    // argument following similar pattern in
    // \Drupal\Core\Database\Connection::expandArguments().
    foreach ($condition['value'] as $value) {
      $condition['where'] .= 'LOWER(:value' . $n . '),';
      $condition['where_args'][':value' . $n] = $value;
      $n++;
    }
    $condition['where'] = trim($condition['where'], ',');
    $condition['where'] .= ')';
    return;
  }
  parent::translateCondition($condition, $sql_query, $case_sensitive);
}