PHPackages                             xp-forge/aggregate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. xp-forge/aggregate

ActiveLibrary[Database &amp; ORM](/categories/database)

xp-forge/aggregate
==================

Data aggregation

v1.1.0(2y ago)05BSD-3-ClausePHPPHP &gt;=7.0.0

Since Aug 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/xp-forge/aggregate)[ Packagist](https://packagist.org/packages/xp-forge/aggregate)[ Docs](http://xp-framework.net/)[ RSS](/packages/xp-forge-aggregate/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

Aggregate data on lists
=======================

[](#aggregate-data-on-lists)

[![Build status on GitHub](https://github.com/xp-forge/aggregate/workflows/Tests/badge.svg)](https://github.com/xp-forge/aggregate/actions)[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/803e78713c19d8d0755ef4be9e8be57ae436a247a5b7a6d23dd41b226ebb48db/68747470733a2f2f706f7365722e707567782e6f72672f78702d666f7267652f6167677265676174652f76657273696f6e2e706e67)](https://packagist.org/packages/xp-forge/aggregate)

Circumvents [`n + 1`-problems](https://stackoverflow.com/questions/97197/what-is-the-n1-selects-problem-in-orm-object-relational-mapping) often occuring with SQL queries.

Example
-------

[](#example)

The following shows how the *Aggregate* class works, firing only **two** SQL queries instead of creating an `n + 1`-problem.

```
use util\data\Aggregate;
use rdbms\DriverManager;

$conn= DriverManager::getConnection($dsn);
$posts= Aggregate::of($conn->query('select * from post'))
  ->collect('comments', ['id' => 'post_id'], function($ids) use($conn) {
    return $conn->query('select * from comment where post_id in (%d)', $ids);
  })
  ->all()
;

// [
//   [
//     'id'       => 1,
//     'body'     => 'The first post',
//     'comments' => [
//        ['id' => 1, 'post_id' => 1, 'body' => 'Re #1: The first post'],
//        ['id' => 2, 'post_id' => 1, 'body' => 'Re #2: The first post'],
//     ]
//   ],
//   [
//     'id'       => 2,
//     'body'     => 'The second post',
//     'comments' => [
//        ['id' => 3, 'post_id' => 2, 'body' => 'Re #1: The second post'],
//     ]
//   ],
// ]
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~562 days

Total

4

Last Release

785d ago

Major Versions

v0.1.0 → v1.0.02019-11-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/07d18d882c8b4aaf3466432f64018214f2771eda333202175431ee7233795376?d=identicon)[thekid](/maintainers/thekid)

---

Top Contributors

[![thekid](https://avatars.githubusercontent.com/u/696742?v=4)](https://github.com/thekid "thekid (20 commits)")

---

Tags

aggregaten-plus-1php7php8sqlxp-frameworkmodulexp

### Embed Badge

![Health badge](/badges/xp-forge-aggregate/health.svg)

```
[![Health](https://phpackages.com/badges/xp-forge-aggregate/health.svg)](https://phpackages.com/packages/xp-forge-aggregate)
```

###  Alternatives

[doctrine/doctrine-orm-module

Laminas Module that provides Doctrine ORM functionality

4407.3M293](/packages/doctrine-doctrine-orm-module)[doctrine/doctrine-module

Laminas Module that provides Doctrine basic functionality required for ORM and ODM modules

3957.9M116](/packages/doctrine-doctrine-module)[doctrine/doctrine-mongo-odm-module

Laminas Module which provides Doctrine MongoDB ODM functionality

86676.6k35](/packages/doctrine-doctrine-mongo-odm-module)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
