PHPackages                             nielbuys/gam-pivot - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. nielbuys/gam-pivot

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nielbuys/gam-pivot
==================

A fork of gonzalo123/gam-pivot

v1.6(3y ago)1371LGPL-3.0-or-laterPHP

Since Apr 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/NielBuys/gam-pivot)[ Packagist](https://packagist.org/packages/nielbuys/gam-pivot)[ RSS](/packages/nielbuys-gam-pivot/feed)WikiDiscussions master Synced today

READMEChangelog (7)DependenciesVersions (8)Used By (0)

A class to pivot tables in PHP

To install

```
composer require nielbuys/gam-pivot

```

Usage examples:

pivot on 'host'

```
$data = Pivot::factory($recordset)
    ->pivotOn(array('host'))
    ->addColumn(array('year', 'month'), array('users', 'clicks',))
    ->fetch();

```

pivot on 'host' with totals

```
$data = Pivot::factory($recordset)
    ->pivotOn(array('host'))
    ->addColumn(array('year', 'month'), array('users', 'clicks',))
    ->fullTotal()
    ->lineTotal()
    ->fetch();

```

pivot on 'host' and 'country'

```
$data = Pivot::factory($recordset)
    ->pivotOn(array('host', 'country'))
    ->addColumn(array('year', 'month'), array('users', 'clicks',))
    ->fullTotal()
    ->pivotTotal()
    ->lineTotal()
    ->fetch();

```

pivot on 'host' and 'country' with calculated columms

```
$averageCbk = function($reg)
{
    return round($reg['clicks']/$reg['users'],2);
};

$data = Pivot::factory($recordset)
    ->pivotOn(array('host', 'country'))
    ->addColumn(array('year', 'month'), array('users', 'clicks', Pivot::callback('average', $averageCbk)))
    ->lineTotal()
    ->pivotTotal()
    ->fullTotal()
    ->typeMark()
    ->fetch();

```

pivot on ‘host’ and ‘country’ with group count

```
$data = Pivot::factory($recordset)
    ->pivotOn(array('host', 'country'))
    ->addColumn(array('year', 'month'), array('users', 'clicks', Pivot::count('count')))
    ->fullTotal()
    ->pivotTotal()
    ->lineTotal()
    ->fetch();

```

The original recordset:

```
$recordset = array(
    array('host' => 1, 'country' => 'fr', 'year' => 2010, 'month' => 1, 'clicks' => 123, 'users' => 4),
    array('host' => 1, 'country' => 'fr', 'year' => 2010, 'month' => 2, 'clicks' => 134, 'users' => 5),
    array('host' => 1, 'country' => 'fr', 'year' => 2010, 'month' => 3, 'clicks' => 341, 'users' => 2),
    array('host' => 1, 'country' => 'es', 'year' => 2010, 'month' => 1, 'clicks' => 113, 'users' => 4),
    array('host' => 1, 'country' => 'es', 'year' => 2010, 'month' => 2, 'clicks' => 234, 'users' => 5),
    array('host' => 1, 'country' => 'es', 'year' => 2010, 'month' => 3, 'clicks' => 421, 'users' => 2),
    array('host' => 1, 'country' => 'es', 'year' => 2010, 'month' => 4, 'clicks' => 22,  'users' => 3),
    array('host' => 2, 'country' => 'es', 'year' => 2010, 'month' => 1, 'clicks' => 111, 'users' => 2),
    array('host' => 2, 'country' => 'es', 'year' => 2010, 'month' => 2, 'clicks' => 2,   'users' => 4),
    array('host' => 3, 'country' => 'es', 'year' => 2010, 'month' => 3, 'clicks' => 34,  'users' => 2),
    array('host' => 3, 'country' => 'es', 'year' => 2010, 'month' => 4, 'clicks' => 1,   'users' => 1),
);

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% 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 ~90 days

Recently: every ~135 days

Total

7

Last Release

1312d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/022aeeea4e5528cd151269780e95e693572ea34c665917fef247b01868c98bc8?d=identicon)[nielbuys](/maintainers/nielbuys)

---

Top Contributors

[![NielBuys](https://avatars.githubusercontent.com/u/8427483?v=4)](https://github.com/NielBuys "NielBuys (18 commits)")[![gonzalo123](https://avatars.githubusercontent.com/u/39072?v=4)](https://github.com/gonzalo123 "gonzalo123 (2 commits)")

### Embed Badge

![Health badge](/badges/nielbuys-gam-pivot/health.svg)

```
[![Health](https://phpackages.com/badges/nielbuys-gam-pivot/health.svg)](https://phpackages.com/packages/nielbuys-gam-pivot)
```

PHPackages © 2026

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