PHPackages                             nochso/orm - 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. nochso/orm

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

nochso/orm
==========

ORM with relations and performance in mind.

1.3.5(10y ago)0255[2 issues](https://github.com/nochso/ORM2/issues)MITPHP

Since Dec 6Pushed 10y ago2 watchersCompare

[ Source](https://github.com/nochso/ORM2)[ Packagist](https://packagist.org/packages/nochso/orm)[ Docs](http://localhost/orm/)[ RSS](/packages/nochso-orm/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (9)Dependencies (1)Versions (11)Used By (0)

nochso/orm
==========

[](#nochsoorm)

[![License](https://camo.githubusercontent.com/6161028f62e57ae6003ff72d02a83ac4c4152948fe59b44ad5111daa9a8b3ea2/68747470733a2f2f706f7365722e707567782e6f72672f6e6f6368736f2f6f726d2f6c6963656e7365)](https://packagist.org/packages/nochso/orm)[![GitHub tag](https://camo.githubusercontent.com/564a1ba5c944bcc8ab33a9d9dde4c0cd83e94a0ed57e09772d3074792e41ff1c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f6e6f6368736f2f4f524d322e737667)](https://github.com/nochso/ORM2/releases)[![Build Status](https://camo.githubusercontent.com/66188b8f98246c66d153029c7af970fccaa70818418674608645311e3053848f/68747470733a2f2f7472617669732d63692e6f72672f6e6f6368736f2f4f524d322e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/nochso/ORM2)[![SensioLabs Insight](https://camo.githubusercontent.com/4c46d81188234a8cc4a53574b97889fb0ed9b56a372874d0a9d126c493a0528a/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f63343639343936372d356130392d343030662d623439332d3732383933353831326337612e737667)](https://insight.sensiolabs.com/projects/c4694967-5a09-400f-b493-728935812c7a)[![Coverage Status](https://camo.githubusercontent.com/5d1c914aa19baf3fbb5b85061411e057e0bcc87f1d5a772ba6aaebf06d9918e7/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6e6f6368736f2f4f524d322f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/nochso/ORM2?branch=master)[![Dependency Status](https://camo.githubusercontent.com/dda9857ead7ecd2f51c3b8b0cec76b94787f7cb7bc0d13acfc7fa8deab94c3b6/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3535386463313233333136333338303031653030303031612f62616467652e737667)](https://www.versioneye.com/user/projects/558dc123316338001e00001a)

A stable ActiveRecord implementation:

- fluent query builder
- tested with MySQL and SQLite
- inspired by [Paris](http://j4mie.github.io/idiormandparis/) but with less magic for better autocompletion

The following conventions are used:

- Every table requires a class inheriting from `nochso\ORM\Model`.
- Class names are snaked\_cased to table names by default.
    - Otherwise you can override `protected static $_tableName`
- Public properties of model classes correspond to column names.

Select all rows from table `blog_post` with title matching "Hello %" ordered by `creation_date`. Then update all titles at once.

```
$posts = BlogPost::select()
    ->like('title', 'Hello %')
    ->orderAsc('creation_date')
    ->all();
foreach ($posts as $primaryKey => $post) {
    $post->title .= ' and goodbye';
}
$posts->save();
```

Installation
------------

[](#installation)

[Get composer](https://getcomposer.org) and require `nochso/orm`.

```
composer require nochso/orm

```

Example
-------

[](#example)

```
use nochso\ORM\Model;
use nochso\ORM\Relation;

class User extends Model {
    /* Actual database table name */
    protected static $_tableName = 'user';
    /* The Subscription class must have a field "user_id" to identify the user's subscriptions */
    protected static $_relations = array(
        'subscriptions' => array(Relation::HAS_MANY, '\TV\Model\Subscription')
    );
    public $id;
    public $name;
    public $password;
    public $token;

    /* Lets you access the relation to the user's subscriptions.
     * Names must match with the key in $_relations */
    public $subscriptions;
}
```

```
// Fetch a user by his name
$john = User::select()->eq('name', 'john doe')->one();

// or achieve the same using the primary key
$sameJohn = User::select()->one($john->id);

echo $john->name; // 'john doe'

// Change and save his name
$john->name = 'herbert';
$john->save();

// Loads the related list of \TV\Model\Subscription instances as defined in User::$_relations['subscriptions']
$john->subscriptions->fetch();

if (count($john->subscriptions) > 0) {
  $john->subscriptions[0]->delete();
}

// Update certain columns of certain users
User::select()
    ->in('user_id', array(3, 6, 15))
    ->update(array('banned' => 1));
```

Change log
==========

[](#change-log)

See the [CHANGELOG](CHANGELOG.md) for the full history of changes between releases.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity69

Established project with proven stability

 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 ~37 days

Total

10

Last Release

3870d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6887618?v=4)[Marcel Voigt](/maintainers/nochso)[@nochso](https://github.com/nochso)

---

Top Contributors

[![nochso](https://avatars.githubusercontent.com/u/6887618?v=4)](https://github.com/nochso "nochso (107 commits)")

---

Tags

databaseormmysqlsqlitestoragemappercrudactive-recordrelationsrelational

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nochso-orm/health.svg)

```
[![Health](https://phpackages.com/badges/nochso-orm/health.svg)](https://phpackages.com/packages/nochso-orm)
```

###  Alternatives

[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58825.2M48](/packages/scienta-doctrine-json-functions)[jv2222/ezsql

Advance database access library. Make interacting with a database ridiculously easy. An universal interchangeable CRUD system.

87211.4k2](/packages/jv2222-ezsql)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

836.0k](/packages/tommyknocker-pdo-database-class)

PHPackages © 2026

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