Updates all records in a table, or a specific record, in the database.
Method Syntax
$db->update($thing, $data)Note
This function replaces the current document / record data with the specified data.
Arguments
Arguments | Type | Description |
|---|---|---|
thing | string, RecordIdor StringRecordId | The table name or the specific |
data | mixed | The document / record data to update. |
Example usage
// 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',
]);Translated query
This function will run the following query in the database.
UPDATE $thing CONTENT $data;