records_count()
Count how many records match a set of filters.
Syntax
records_count(table, filters?)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
table |
string | yes | Table name or database table id. |
filters |
array | no | Filter conditions — see records_query(). Omit for a total count. |
Returns
An integer count.
Example
$open = records_count("tickets", [
["field" => "status", "op" => "!=", "value" => "closed"]
]);
if ( $open > 50 ) {
record_comment("dashboards", $record["_meta"]["id"], "Backlog over 50: " . $open);
}
Example output
63
Notes
- Counting is capped at 1000 — use it for thresholds and gating, not exact totals on very large tables.
See also: records_query()