Skip to content

SET clause

Marijn van Wezel edited this page Dec 15, 2022 · 5 revisions

The SET clause is used to update labels on nodes and properties on nodes and relationships. It accepts a number of expressions to set.

Query::set(Label|PropertyReplacement|(Label|PropertyReplacement)[] $expressions): Query

Parameters

  • $expressions : A single expression to set, or a non-empty list of expressions to set.

Relevant methods

  • add(Label|PropertyReplacement ...$expressions): self : Add one or more expressions to this SET clause.

Examples

$n = node()->withProperties(['name' => 'Andy']);
$query = query()
    ->match($n)
    ->set($n->property('surname')->replaceWith('Taylor'))
    ->returning([$n->property('name'), $n->property('surname')])
    ->build();

$this->assertStringMatchesFormat("MATCH (%s {name: 'Andy'}) SET %s.surname = 'Taylor' RETURN %s.name, %s.surname", $query);

External links