PHPackages                             erwang/korm - 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. erwang/korm

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

erwang/korm
===========

ORM for PHP

v2.0.0(8y ago)0102[2 PRs](https://github.com/erwang/korm/pulls)GNU-GPL3PHP

Since Dec 29Pushed 4y ago1 watchersCompare

[ Source](https://github.com/erwang/korm)[ Packagist](https://packagist.org/packages/erwang/korm)[ RSS](/packages/erwang-korm/feed)WikiDiscussions master Synced 4w ago

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

KORM
====

[](#korm)

ORM in PHP ⛔️ DEPRECATED

Setup
-----

[](#setup)

The Connection class setup must be call first.

```
$connection = \KORM\Connection::setup('name','pdo_dsn', 'username', 'password');
```

A connection to a mysql database :

```
$connection = \KORM\Connection::setup('connectionName','mysql:host=localhost;dbname=database', 'username', 'password');
```

with options :

```
$connection = \KORM\Connection::setup('connectionName','mysql:host=localhost;dbname=database', 'username', 'password', array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''));
```

Create a class
--------------

[](#create-a-class)

Each table in database requires a class with the same name :

```
class Table extends \KORM\Object{
}
```

*name class is converted to lower case*For example, to store books :

```
class Book extends \KORM\Object{
}
```

The `Book` objects will be store in `book` table

Define connection
-----------------

[](#define-connection)

```
Book::setConnection($connection);
```

Get a row from id
-----------------

[](#get-a-row-from-id)

```
$book = new Book($id);
```

will load in `$book` all the data in table `book` with id=1

Create a row
------------

[](#create-a-row)

```
$book = new Book();
```

Store an object
---------------

[](#store-an-object)

```
$book = new Book($id);
$book->title='Les Misérables';
$book->store();
```

Delete an object
----------------

[](#delete-an-object)

```
$book = new Book($id);
$book->delete();
```

Find objects
------------

[](#find-objects)

### Find one Object

[](#find-one-object)

```
$book = Book::findOne(['title'=>'Les Misérables']);
```

This return one Book (the first found)

### Find multiple Objects

[](#find-multiple-objects)

```
$authors = Author::find(['nationality'=>'French']);
```

This will return an array with all french authors

If you need complex where clause, you can use where

```
$books = Book::where('pages>:nbpages',['nbpages'=>100]);
```

This will return an array with books with more than 100 pages

If you want more complex queries :

```
$books = Book::query('select book.* from book,author where author.id=:author_id and pages>:nbpages and author.id=book.author_id',['nbpages'=>100,'author_id'=>1]);
```

This will return an array with books with more than 100 pages from author with id 1

```
$books = Book::getAll();
```

This will return all books in table

Relations
---------

[](#relations)

### One to many

[](#one-to-many)

```
//create a book
$lesMiserables = new Book();
$lesMiserables->title='Les Misérables';
$lesMiserables->store();

//create an author
$hugo=new Author();
$hugo->name='Victor Hugo';
$hugo->store();

//create a relation
$lesMiserables->author=$hugo;
$lesMiserables->store();

//get the book
$book = new Book($lesMiserables->id);
$author = $book->author; //return the object Author from table author
```

### many to many

[](#many-to-many)

```
//create tags
$tag1=new Tag();
$tag1->text='french';
$tag1->store();

$tag2=new Tag();
$tag2->text='Roman';
$tag2->store();
$lesMiserables->tag=[$tag1,$tag2];
$lesMiserables->store();

//find book from many
$booksWithFrenchTag = $tag1->book;
```

Count
-----

[](#count)

```
//get the number of books
Book::count();

//get the number of books from an author
Book::count(['author_id'=>$author->id]);
```

Populate an object
------------------

[](#populate-an-object)

```
//get data from an array
$post=['firstname'=>'Marcel','lastname'=>'Proust'];
//create a new author
$author=new Author();
$author->populate($post);
$author->store();
```

Truncate table
--------------

[](#truncate-table)

```
//with foreign key check
Author::truncate();
//without foreign key check
Author::truncate(false);
```

Drop table
----------

[](#drop-table)

```
//with foreign key check
Author::drop();
//without foreign key check
Author::drop(false);
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

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

Recently: every ~42 days

Total

7

Last Release

3259d ago

Major Versions

v0.0.15 → v1.0.02017-01-18

v1.0.4 → v2.0.02017-07-28

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/425167?v=4)[Erwan](/maintainers/erwang)[@erwang](https://github.com/erwang)

---

Top Contributors

[![erwang](https://avatars.githubusercontent.com/u/425167?v=4)](https://github.com/erwang "erwang (12 commits)")

---

Tags

ormmapping

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/erwang-korm/health.svg)

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

###  Alternatives

[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8441.6M87](/packages/propel-propel1)[atlas/orm

An ORM for your persistence model (not your domain model).

429142.5k12](/packages/atlas-orm)[atlas/cli

Command-line interface for Atlas.

14127.7k10](/packages/atlas-cli)[proesio/pipe

PIPE - ORM en Español.

149.5k1](/packages/proesio-pipe)[bauer01/unimapper

Universal mapping tool for collecting data from different sources

102.6k6](/packages/bauer01-unimapper)[bauer01/unimapper-flexibee

Flexibee implementation for UniMapper

101.1k](/packages/bauer01-unimapper-flexibee)

PHPackages © 2026

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