PHPackages                             rrelmy/rorm - 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. rrelmy/rorm

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

rrelmy/rorm
===========

Simple lightweight ORM

1.0.0(10y ago)12.7k1[1 PRs](https://github.com/rrelmy/rorm/pulls)MITPHPPHP &gt;=5.3.0

Since Feb 21Pushed 8y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

Rorm
====

[](#rorm)

- Author: Rémy M. Böhler
- License: MIT
- Version: 0.1

[![Build Status](https://camo.githubusercontent.com/c7bc3cadd97e2e6a2d79c205476abd070fbad97817e91e9a91d9c2dfa3b614b8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7272656c6d792f726f726d2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/rrelmy/rorm/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/ae7504048a50df2d76dd6ba9a9f63296b3a82925dfb991ae8847676002d7b078/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7272656c6d792f726f726d2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/rrelmy/rorm/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f26381b8c4f3bae5905c773130ee29ebde8ed650e46e815f478025d73963282f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7272656c6d792f726f726d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/rrelmy/rorm/?branch=master)

[![Build Status](https://camo.githubusercontent.com/53c9a24360a2a637a009bb89b914cabd89b77f605f5ad08d65eae8aa380b1c8a/68747470733a2f2f7472617669732d63692e6f72672f7272656c6d792f726f726d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rrelmy/rorm)

Requirements
------------

[](#requirements)

- PHP 5.3

PHP 5.3 requires a `JsonSerializable` polyfill for the Model.

With PHP 5.5 we could ditch the `QueryIterator` and use `yield`. Yield seems to have a little bit bigger memory footprint.

Goals
-----

[](#goals)

- Easy to use, easy to extend
- Minimalistic ORM
- Fast and low memory footprint
- compound key support
- Almost 100% test code coverage

TODO
----

[](#todo)

- check for possible model loaded hook
- check if `autoId` could be ditched
- consider `setExpr` (may be bad because until the model is loaded again the data is 'weird')
- grouping/having support inside the `QueryBuilder`
- Documentation

Ideas
-----

[](#ideas)

- Cache

Usage
-----

[](#usage)

### General

[](#general)

CodeDescription`Rorm::setDatabase($dbh);`Set default database connection`Rorm::getDatabase();`Retrieve the PDO object`Rorm::isMySQL($dbh)`Check for MySQL connection`Rorm::isSQLite($dbh)`Check for SQLite connection`Rorm::quote($dbh, $value)`Returns the quoted value`Rorm::getIdentifierQuoter()`Returns a closure to quote identifiers### Model

[](#model)

CodeDescription`MyModel::getTable();`Get the table name`MyModel::getDatabase();`Get the database connection`MyModel::create();`Create a new instance`MyModel::find($id);`Find the model with specific `$id``MyModel::findAll();`Get all available models`MyModel::query();`Create a new `QueryBuilder` instance`MyModel::customQuery($sql);`Create a custom queryCodeDescription`$model->getId()`Get the id of the current model`$model->hasId()`Check if the model has a id specified`$model->save()`Save current data to the database`$model->delete()`Delete entry from the database`$model->getData()`Get all data as array`$model->setData($data)`Overwrite the data`$model->get($name)`Get property`$model->set($name, $value)`Set property`$model->has($name)`Check if data exists`$model->remove($name)`Remove property`$model->copyDataFrom($data)`Copy data from object or array### QueryBuilder

[](#querybuilder)

CodeDescription`$query->distinct()`Use `DISTINCT``$query->selectAll()`Select all data (default)`$query->select($column[, $as])`Select specific column`$query->selectExpr($expr[, $as])`Select expression`$query->where($column, $value)`Add `WHERE c = ?``$query->whereNot($column, $value)`Add `WHERE c != ?``$query->whereId($id)`Add `WHERE id = ?``$query->whereExpr($column, $expr)`Add `WHERE c = EXPR()``$query->whereRaw($where[, $params])`Add custom where clause`$query->whereLt($column, $value)`Add `WHERE c < ?``$query->whereLte($column, $value)`Add `WHERE c whereGt($column, $value)`Add `WHERE c > ?``$query->whereGte($column, $value)`Add `WHERE c >= ?``$query->whereNull($column)`Add `WHERE c IS NULL ?``$query->whereNotNull($column)`Add `WHERE c IS NOT NULL ?``$query->whereIn($column, $data)`Add `WHERE c IN (?, ?, ?)``$query->orderByAsc($column)`Add `ORDER BY c ASC``$query->orderByDesc($column)`Add `ORDER BY c DESC``$query->orderByExpr($column[, $params])`Add `ORDER BY EXPR()``$query->limit(10)`Add `LIMIT 10``$query->offset(10)`Add `OFFSET 10``$query->findColumn()`Retrieve first column of first entry`$query->findMany()`Retrieve entries via an iterator`$query->findAll()`Retrieve entries as array`$query->count()`Count the resultsRelations
---------

[](#relations)

There is no special support for relationships, but its easy to integrate them yourself.

Error handling
--------------

[](#error-handling)

It is recommended to use the PDO exception error mode. Rorm has no special error handling and does not catch thrown `PDOException`'s!

```
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

```

Unbuffered queries
------------------

[](#unbuffered-queries)

You can use unbuffered queries with the findMany method, but you have to be aware that no queries can be executed until the iteration is finished.

No special methods are supplied for configure unbuffered queries. You may use the PDO attributes yourself.

Multiple database connections
-----------------------------

[](#multiple-database-connections)

You can add multiple database connections to the Rorm config with the `setDatabase($dbh, 'name')` method.

Each model can have a different database connection which can be configure with the `$_connection` property.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

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

Unknown

Total

1

Last Release

3782d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/442683?v=4)[Rémy](/maintainers/rrelmy)[@rrelmy](https://github.com/rrelmy)

---

Top Contributors

[![rrelmy](https://avatars.githubusercontent.com/u/442683?v=4)](https://github.com/rrelmy "rrelmy (41 commits)")

---

Tags

ormphp

### Embed Badge

![Health badge](/badges/rrelmy-rorm/health.svg)

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

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

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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