function Condition::translateCondition

Same name in this branch
  1. 9 core/lib/Drupal/Core/Entity/Query/Sql/Condition.php \Drupal\Core\Entity\Query\Sql\Condition::translateCondition()
Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Query/Sql/Condition.php \Drupal\Core\Entity\Query\Sql\Condition::translateCondition()
  2. 8.9.x core/lib/Drupal/Core/Entity/Query/Sql/pgsql/Condition.php \Drupal\Core\Entity\Query\Sql\pgsql\Condition::translateCondition()
  3. 10 core/lib/Drupal/Core/Entity/Query/Sql/Condition.php \Drupal\Core\Entity\Query\Sql\Condition::translateCondition()
  4. 10 core/lib/Drupal/Core/Entity/Query/Sql/pgsql/Condition.php \Drupal\Core\Entity\Query\Sql\pgsql\Condition::translateCondition()
  5. 11.x core/lib/Drupal/Core/Entity/Query/Sql/Condition.php \Drupal\Core\Entity\Query\Sql\Condition::translateCondition()
  6. 11.x core/lib/Drupal/Core/Entity/Query/Sql/pgsql/Condition.php \Drupal\Core\Entity\Query\Sql\pgsql\Condition::translateCondition()

Overrides Condition::translateCondition

File

core/lib/Drupal/Core/Entity/Query/Sql/pgsql/Condition.php, line 16

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'] = [];
        // Only use the array values in case an associative array is passed as an
        // argument following similar pattern in
        // \Drupal\Core\Database\Connection::expandArguments().
        $where_prefix = str_replace('.', '_', $condition['real_field']);
        foreach ($condition['value'] as $key => $value) {
            $where_id = $where_prefix . $key;
            $condition['where'] .= 'LOWER(:' . $where_id . '),';
            $condition['where_args'][':' . $where_id] = $value;
        }
        $condition['where'] = trim($condition['where'], ',');
        $condition['where'] .= ')';
    }
    parent::translateCondition($condition, $sql_query, $case_sensitive);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.