record_delete()
Delete a record from a table.
Syntax
record_delete(table, id, opts?)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
table |
string | yes | Table name or database table 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()