PHPackages                             apinnecke/composite-number-range-behavior - 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. apinnecke/composite-number-range-behavior

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

apinnecke/composite-number-range-behavior
=========================================

A behavior providing composite number ranges with a foreign key and a composite key.

0.2.1(10y ago)16.3k3MITPHP

Since Dec 20Pushed 10y ago2 watchersCompare

[ Source](https://github.com/apinnecke/composite-number-range-behavior)[ Packagist](https://packagist.org/packages/apinnecke/composite-number-range-behavior)[ RSS](/packages/apinnecke-composite-number-range-behavior/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

### CompositeNumberRangeBehavior

[](#compositenumberrangebehavior)

A behavior for Propel 2 which provides number ranges in combination of a composite key. **This Behavior only works in MySQL!**

[![Build Status](https://camo.githubusercontent.com/7f7e4364491734338f5dca44efaa5389a17a6298870a073ce8e94774856af889/68747470733a2f2f7472617669732d63692e6f72672f6170696e6e65636b652f636f6d706f736974652d6e756d6265722d72616e67652d6265686176696f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/apinnecke/composite-number-range-behavior)[![Latest Stable Version](https://camo.githubusercontent.com/77758839e128e91f7817228fcce25e993b0481ad6681b2d309e422c8872d62cb/68747470733a2f2f706f7365722e707567782e6f72672f6170696e6e65636b652f636f6d706f736974652d6e756d6265722d72616e67652d6265686176696f722f762f737461626c652e706e67)](https://packagist.org/packages/apinnecke/composite-number-range-behavior)[![Total Downloads](https://camo.githubusercontent.com/8e2559d96f4dcf941d46d01ceeefb5a9cb46e7634fc34aa1f74048f02807bd90/68747470733a2f2f706f7365722e707567782e6f72672f6170696e6e65636b652f636f6d706f736974652d6e756d6265722d72616e67652d6265686176696f722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/apinnecke/composite-number-range-behavior)

---

Dafuq? Number Range? What's that?
---------------------------------

[](#dafuq-number-range-whats-that)

Consider having a table with an autoincrement id field, a foreign key and an composite id field behaving as an autoincrement field, but starting at zero for every new foreign id value. Example:

```

```

Example content of document table:

iduser\_iduser\_document\_id111212321422531632713814As you can see, `user_document_id` is starting at zero for every different `user_id`! This is called a number range. *Yay*

How does this Behavior work?
----------------------------

[](#how-does-this-behavior-work)

The generation of the user\_document\_id is done via a trigger which is created automatically by a custom MySQLPlatform provided by this behavior. The current id is stored in a sequence\_table to prevent duplicate keys when a row is deleted from the `document` table.

Registering the Platform
------------------------

[](#registering-the-platform)

In `app/config/config.yml` add the platform for your connection name:

```
propel:
    generator:
        defaultConnection: default
        connections:       [ default ]
        platformClass:     \APinnecke\CompositeNumberRange\Platform\MysqlPlatform
```

Add behavior to table
---------------------

[](#add-behavior-to-table)

Following the user &lt;-&gt; document example:

```

```

Now the following things will be auto generated: - The `user_id` column - A ForeignKey from `document`.`user_id` to `user`.`id`- The `user_document_id` column - A Unique Index with `user_id` and `user_document_id`- A sequence table `user_sequence` consisting out of `table_name`, `user_id` and `user_max_document_id` columns. - The Trigger `setDocumentUserId`

Code Example:
-------------

[](#code-example)

```
$user = new \User();
$user->setName('Alfred');
$user->save();

$document = new \Document();
$document->setUser($user);
$document->save();

$userDocumentId = $document->getUserDocumentId();
// $userDocumentId contains 1
```

Migrations Notice
-----------------

[](#migrations-notice)

Because `propel:migrations:diff` does not know anything about triggers, they have to be checked via SQL Statement. If you use triggers and change something on any table having triggers appended, they will always appear in your `down()` section of the migration. At the moment you have to remove them by hand, this bug will be solved in the future during Propel 2 release.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

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

Total

5

Last Release

3952d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d97abc211bc7bd5ea8eb576c81568320471d7b369d2a2572b7662c69329fe565?d=identicon)[apinnecke](/maintainers/apinnecke)

---

Top Contributors

[![aklinkert](https://avatars.githubusercontent.com/u/1313774?v=4)](https://github.com/aklinkert "aklinkert (17 commits)")[![marcj](https://avatars.githubusercontent.com/u/450980?v=4)](https://github.com/marcj "marcj (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/apinnecke-composite-number-range-behavior/health.svg)

```
[![Health](https://phpackages.com/badges/apinnecke-composite-number-range-behavior/health.svg)](https://phpackages.com/packages/apinnecke-composite-number-range-behavior)
```

###  Alternatives

[ishanvyas22/asset-mix

Asset Mix plugin for CakePHP

3375.4k2](/packages/ishanvyas22-asset-mix)[prgayman/laravel-zatca

Laravel package a helper to Generate the QR code and signed it for ZATCA E-invoicing

2926.9k1](/packages/prgayman-laravel-zatca)[ducks-project/spl-types

Polyfill Module for SplType PHP extension. This extension aims at helping people making PHP a stronger typed language and can be a good alternative to scalar type hinting. It provides different typehandling classes as such as integer, float, bool, enum and string

1032.4k](/packages/ducks-project-spl-types)

PHPackages © 2026

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