record_get()
Fetch one record from a table by its id.
Syntax
record_get(table, id)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
table |
string | yes | Table name or database table id. |
id |
int | yes | The record's primary key. |
Returns
The record as an array (fields keyed by field id, plus _meta), or null if no record with that id exists.
Example
$deal = record_get("deals", $record["_meta"]["id"]);
if ( $deal ) {
sys_log("Stage: " . $deal["stage"]);
}
Example output
[
"name" => "Acme renewal",
"stage" => "negotiation",
"amount" => 12000,
"_meta" => ["id" => 87, "title" => "Acme renewal"]
]
Notes
- Returns
nullrather than throwing when the record is missing — always check before using the result. - To fetch many records, use records_query().
See also: record_update(), records_query()