PHPackages                             romeoz/rock-db - 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. romeoz/rock-db

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

romeoz/rock-db
==============

Object Relational Mapping (ORM) for PHP.

0.15.0(10y ago)51.0k4MITPHPPHP &gt;=5.4.0

Since Mar 5Pushed 10y ago1 watchersCompare

[ Source](https://github.com/romeOz/rock-db)[ Packagist](https://packagist.org/packages/romeoz/rock-db)[ RSS](/packages/romeoz-rock-db/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (16)Used By (4)

Object Relational Mapping (ORM) for PHP
=======================================

[](#object-relational-mapping-orm-for-php)

Independent fork by [Yii2 Database 2.0.4](https://github.com/yiisoft/yii2).

[![Latest Stable Version](https://camo.githubusercontent.com/f26d90f063d3208e73dfa3fb5dffb7ab434decaae3eef512b457fcdc682356cb/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d64622f762f737461626c652e737667)](https://packagist.org/packages/romeOz/rock-db)[![Total Downloads](https://camo.githubusercontent.com/a231ea6ac95591e09e71866a334c3a8cda19cf4ebfc7fcd95667fb01609bfb80/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d64622f646f776e6c6f6164732e737667)](https://packagist.org/packages/romeOz/rock-db)[![Build Status](https://camo.githubusercontent.com/ae2998f0a04fc1cacefbeeaf0075aa2eea43d5c2260dbf5afaf59b07bb1bd418/68747470733a2f2f7472617669732d63692e6f72672f726f6d654f7a2f726f636b2d64622e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/romeOz/rock-db)[![HHVM Status](https://camo.githubusercontent.com/3a775753ddbb6bd8304b173a908cbce8ca64f50a1cafcb687811c7bdb59342de/687474703a2f2f6868766d2e683463632e64652f62616467652f726f6d656f7a2f726f636b2d64622e737667)](http://hhvm.h4cc.de/package/romeoz/rock-db)[![Coverage Status](https://camo.githubusercontent.com/32cb56541b06eaf8fda3a6a4f1e4b39552fb5a0997162e8b9f6ab62b1a12a26b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f726f6d654f7a2f726f636b2d64622f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/romeOz/rock-db?branch=master)[![License](https://camo.githubusercontent.com/d12e569a9ea66a0ac88b7ee71494e516dc90c345c94cffa90ce76ce93110f09c/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d64622f6c6963656e73652e737667)](https://packagist.org/packages/romeOz/rock-db)

Features
--------

[](#features)

- Supports the following databases out of box:
    - [MySQL](http://www.mysql.com/)
    - [MariaDB](https://mariadb.com/)
    - [SQLite](http://sqlite.org/)
    - [PostgreSQL](http://www.postgresql.org/)
    - [CUBRID](http://www.cubrid.org/): version 9.3 or higher.
    - [Oracle](http://www.oracle.com/us/products/database/overview/index.html)
    - [MSSQL](https://www.microsoft.com/en-us/sqlserver/default.aspx): version 2008 or higher.
- Query Builder/DBAL/DAO: Querying the database using a simple abstraction layer
- Active Record: The Active Record ORM, retrieving and manipulating records, and defining relations
- Migrations
- Behaviors (SluggableBehavior, TimestampBehavior,...)
- Data Provider
- **Validation and Sanitization rules for AR (Model)**
- **Caching queries**
- **Standalone module/component for [Rock Framework](https://github.com/romeOz/rock)**

> Bolded features are different from [Yii2 Database](https://github.com/yiisoft/yii2).

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

[](#installation)

From the Command Line:

`composer require romeoz/rock-db`

In your composer.json:

```
{
    "require": {
        "romeoz/rock-db": "*"
    }
}
```

Quick Start
-----------

[](#quick-start)

\####Query Builder

```
$rows = (new \rock\db\Query())
    ->select('id, name')
    ->from('users')
    ->limit(10)
    ->all();
```

\####Active Record

```
// find
$users = Users::find()
    ->where(['status' => Users::STATUS_ACTIVE])
    ->orderBy('id')
    ->all();

// insert
$users = new Users();
$users ->name = 'Tom';
$users ->save();
```

Documentation
-------------

[](#documentation)

- [Basic](https://github.com/yiisoft/yii2/blob/master/docs/guide/db-dao.md): Connecting to a database, basic queries, transactions, and schema manipulation
- [Query Builder](https://github.com/yiisoft/yii2/blob/master/docs/guide/db-query-builder.md)
- [Active Record](https://github.com/yiisoft/yii2/blob/master/docs/guide/db-active-record.md)
- [Migrations](https://github.com/yiisoft/yii2/blob/master/docs/guide/db-migrations.md): Apply version control to your databases in a team development environment
- [Data Providers](https://github.com/romeOz/rock-db/blob/master/docs/data-provider.md)

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

[](#requirements)

- **PHP 5.4+**
- For validation rules a model required [Rock Validate](https://github.com/romeOz/rock-validate): `composer require romeoz/rock-validate`
- For sanitization rules a model required [Rock Sanitize](https://github.com/romeOz/rock-sanitize): `composer require romeoz/rock-sanitize`
- For using behaviors a model required [Rock Behaviors](https://github.com/romeOz/rock-behaviors): `composer require romeoz/rock-behaviors`
- For using Data Provider required [Rock Data Provider](https://github.com/romeOz/rock-dataprovider/): `composer require romeoz/rock-dataprovider`
- For caching queries required [Rock Cache](https://github.com/romeOz/rock-behaviors): `composer require romeoz/rock-cache`

> All unbolded dependencies is optional

License
-------

[](#license)

The Object Relational Mapping (ORM) is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity56

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

Every ~17 days

Recently: every ~25 days

Total

15

Last Release

3844d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23c5d84a59845d751cb69f5469986579b9312c54c898b366fefdc05baaa80a9c?d=identicon)[romeOz](/maintainers/romeOz)

---

Top Contributors

[![romeOz](https://avatars.githubusercontent.com/u/3135712?v=4)](https://github.com/romeOz "romeOz (228 commits)")

---

Tags

persistencedatabaseormmysqlsqlitepostgresqldbalmssqlactive-recordrdbmsdaoCUBRID

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/romeoz-rock-db/health.svg)

```
[![Health](https://phpackages.com/badges/romeoz-rock-db/health.svg)](https://phpackages.com/packages/romeoz-rock-db)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[dibi/dibi

Dibi is Database Abstraction Library for PHP

5013.8M120](/packages/dibi-dibi)[cycle/database

DBAL, schema introspection, migration and pagination

64690.9k31](/packages/cycle-database)[cycle/orm

PHP DataMapper ORM and Data Modelling Engine

1.3k835.4k65](/packages/cycle-orm)[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.

845.7k](/packages/tommyknocker-pdo-database-class)[dg/adminer-custom

Customization for Adminer, the best database management tool written in PHP.

134765.7k16](/packages/dg-adminer-custom)

PHPackages © 2026

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