translateCondition example

      // 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);
  }

}
// If the field is trying to query on %delta for a single value field         // then the only supported delta is 0. No other value than 0 makes         // sense. \Drupal\Core\Entity\Query\Sql\Tables::addField() returns 0 as         // the field name for single value fields when querying on their %delta.         if ($field === 0) {
          if ($condition['value'] != 0) {
            $conditionContainer->alwaysFalse();
          }
          continue;
        }
        $condition['real_field'] = $field;
        static::translateCondition($condition$sql_query$tables->isFieldCaseSensitive($condition['field']));

        // Add the translated conditions back to the condition container.         if (isset($condition['where']) && isset($condition['where_args'])) {
          $conditionContainer->where($condition['where']$condition['where_args']);
        }
        else {
          $conditionContainer->condition($field$condition['value']$condition['operator']);
        }
      }
    }
  }

  
if ($condition['field'] instanceof ConditionAggregateInterface) {
        $sql_condition = $sql_query->getConnection()->condition($condition['field']->getConjunction());
        // Add the SQL query to the object before calling this method again.         $condition['field']->sqlQuery = $sql_query;
        $condition['field']->compile($sql_condition);
        $sql_query->condition($sql_condition);
      }
      else {
        $type = ((strtoupper($this->conjunction) == 'OR') || ($condition['operator'] == 'IS NULL')) ? 'LEFT' : 'INNER';
        $field = $tables->addField($condition['field']$type$condition['langcode']);
        $condition_class = QueryBase::getClass($this->namespaces, 'Condition');
        $condition_class::translateCondition($condition$sql_query$tables->isFieldCaseSensitive($condition['field']));
        $function = $condition['function'];
        $placeholder = ':db_placeholder_' . $conditionContainer->nextPlaceholder();
        $sql_field_escaped = '[' . str_replace('.', '].[', $field) . ']';
        $conditionContainer->having("$function($sql_field_escaped) {$condition['operator']} $placeholder", [$placeholder => $condition['value']]);
      }
    }
  }

  /** * {@inheritdoc} */
  
Home | Imprint | This part of the site doesn't use cookies.