Rs
in package
Functions to hack database query result sets
Table of Contents
Methods
- groupByField() : array<string|int, mixed>
- Groups rows in a resultset (e.g. by category, date, ...)
Methods
groupByField()
Groups rows in a resultset (e.g. by category, date, ...)
public
static groupByField(array<string|int, mixed>|PDOStatement $rs, string $group_id[, array<string|int, mixed> $group_fields = array() ]) : array<string|int, mixed>
Parameters
- $rs : array<string|int, mixed>|PDOStatement
-
Resultset, which MUST have an id column
- $group_id : string
-
The column with the field to group by, e.g. cat_id
- $group_fields : array<string|int, mixed> = array()
-
Extra data for the group segments. The keys are the fields for each group, and the values are the corresponding field names in the result set. For example, ['name' => 'cat_name', 'slug' => 'cat_slug']
Return values
array<string|int, mixed> —Grouped rows. The key is the group id, and the value is an array with key 'rows', and a matching key for each of the specified $group_fields