Submitted by
Dmitro
on
Update the 'pair' field using an expression to concatenate the fields.
$database = \Drupal::service('database');
$database->update('mono_currency_rates')
->expression('pair', "CONCAT(currency_code_sell, '/', currency_code_buy)")
->isNull('pair')
->execute();
Sort:
$query->addExpression("FIELD(mono_currency_rates.currency, 'USD', 'EUR', 'GBP')", 'currency_order');
$query->orderBy('currency_order', 'ASC');
Views query join:
$definition = [
'table' => 'field_value_log',
'field' => 'entity_id',
'left_table' => 'event__field_event_instructor',
'left_field' => 'field_event_instructor_target_id',
'operator' => '=',
'extra' => [
['field' => 'entity_type', 'value' => 'event_instructor'],
['field' => 'bundle', 'value' => 'event_instructor'],
['field' => 'field_name', 'value' => 'field_instructor'],
['field' => 'delta', 'value' => 0],
['field' => 'is_last', 'value' => 1],
],
'type' => 'INNER',
];
$join = $this->joinHandler->createInstance('standard', $definition);
$this->query->addRelationship('instructor_field_value_log', $join, 'field_value_log');