SproutCMS

This is the code documentation for the SproutCMS project

function groupByField()

Groups rows in a resultset (e.g. by category, date, ...)

Usage

array Rs::groupByField ( array|PDOStatement $rs , string $group_id , array $group_fields );

Arguments

  1. array|PDOStatement $rs
    Resultset, which MUST have an id column
  2. string $group_id
    The column with the field to group by,
           e.g. cat_id
  3. array $group_fields
    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 value

  • array
    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