record_delete()
Delete a record from a table.
Syntax
record_delete(table, id, opts?)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
table |
string or number | yes | The table's name, its database table name, or its numeric table id. Read the id from $table at run time (for example $table["fields"]["client"]["lookup_table"]); never type one into your code, because table ids change when a workspace is copied. A table whose name happens to be a number always wins over the table with that id. |
id |
int | yes | The record's primary key. |
opts |
array | no | Options. ["silent" => true] suppresses notifications to the record's followers. |
Returns
true on success. Throws if the record is not found.
Example
$stale = records_query("logs", [
["field" => "created", "op" => "<", "value" => "2024-01-01"]
]);
foreach ( $stale as $row ) {
record_delete("logs", $row["_meta"]["id"]);
}
Example output
true
Notes
- Deletion is permanent and recorded in activity history; it does not trigger other automations.
- Use records_query() to find the records to delete first.
See also: records_query(), record_update()