function Merge::expression

Same name in other branches
  1. 9 core/lib/Drupal/Core/Database/Query/Merge.php \Drupal\Core\Database\Query\Merge::expression()
  2. 10 core/lib/Drupal/Core/Database/Query/Merge.php \Drupal\Core\Database\Query\Merge::expression()
  3. 11.x core/lib/Drupal/Core/Database/Query/Merge.php \Drupal\Core\Database\Query\Merge::expression()

Specifies fields to be updated as an expression.

Expression fields are cases such as counter = counter + 1. This method takes precedence over MergeQuery::updateFields() and its wrappers, MergeQuery::key() and MergeQuery::fields().

Parameters

$field: The field to set.

$expression: The field will be set to the value of this expression. This parameter may include named placeholders.

$arguments: If specified, this is an array of key/value pairs for named placeholders corresponding to the expression.

Return value

$this The called object.

File

core/lib/Drupal/Core/Database/Query/Merge.php, line 194

Class

Merge
General class for an abstracted MERGE query operation.

Namespace

Drupal\Core\Database\Query

Code

public function expression($field, $expression, array $arguments = NULL) {
    $this->expressionFields[$field] = [
        'expression' => $expression,
        'arguments' => $arguments,
    ];
    $this->needsUpdate = TRUE;
    return $this;
}

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