• Start

Languages

/

PHP

/

Methods

update

The ->update() method for the SurrealDB SDK for Rust updates all or specific records in the database if they exist.

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

Method Syntax

$db->update($thing, $data)
ArgumentsTypeDescription
thing string, RecordId or StringRecordId The table name or the specific RecordId to update.
data mixed The document / record data to update.
// Update all records in a table
$people = $db->update('person');

// Update a record with a specific ID
$person = $db->update(new RecordId('person', 'tobie'), [
"name" => 'Tobie',
"settings" => [
"active" => true,
"marketing" => true,
],
]);

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

This function will run the following query in the database.

UPDATE $thing CONTENT $data;

Was this page helpful?