• Start

v1 (stable)

/

Methods

merge

The ->merge() method for the SurrealDB SDK for PHP merges record data with the specified data.

Modifies all records in a table, or a specific record, in the database.

Method Syntax
$db->merge($thing, $data)
Note

This function merges the current document / record data with the specified data.

Arguments

Type

Description

thingstring

,

RecordId

or

StringRecordId

The table name or the specific RecordId to merge.

datamixed

The document / record data to merge.

// Update all records in a table
$people = $db->merge('person', [
	"updated_at" => new Date(),
]);

// Update a record with a specific ID
$person = $db->merge(new RecordId('person', 'tobie'), [
	"updated_at" => new Date(),
	"settings" => [
		"active" => true,
	],
]);

// The content you are merging the record with might differ from the return type
$record = $db->merge(new RecordId('person', 'tobie'), [
	"name" => 'Tobie',
]);

This function will run the following query in the database.

UPDATE $thing MERGE $data;

Was this page helpful?