Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Core / Entity / Query / Sql / pgsql / Condition.php
1 <?php
2
3 namespace Drupal\Core\Entity\Query\Sql\pgsql;
4
5 use Drupal\Core\Database\Query\SelectInterface;
6 use Drupal\Core\Entity\Query\Sql\Condition as BaseCondition;
7
8 /**
9  * Implements entity query conditions for PostgreSQL databases.
10  */
11 class Condition extends BaseCondition {
12
13   /**
14    * {@inheritdoc}
15    */
16   public static function translateCondition(&$condition, SelectInterface $sql_query, $case_sensitive) {
17     if (is_array($condition['value']) && $case_sensitive === FALSE) {
18       $condition['where'] = 'LOWER(' . $sql_query->escapeField($condition['real_field']) . ') ' . $condition['operator'] . ' (';
19       $condition['where_args'] = [];
20
21       $n = 1;
22       // Only use the array values in case an associative array is passed as an
23       // argument following similar pattern in
24       // \Drupal\Core\Database\Connection::expandArguments().
25       foreach ($condition['value'] as $value) {
26         $condition['where'] .= 'LOWER(:value' . $n . '),';
27         $condition['where_args'][':value' . $n] = $value;
28         $n++;
29       }
30       $condition['where'] = trim($condition['where'], ',');
31       $condition['where'] .= ')';
32       return;
33     }
34     parent::translateCondition($condition, $sql_query, $case_sensitive);
35   }
36
37 }