PHPackages                             berlindb/core - 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. berlindb/core

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

berlindb/core
=============

A collection of PHP classes and functions that aims to provide an ORM-like experience and interface to WordPress database tables.

3.0.0(2mo ago)271468.5k↓41.5%27[28 issues](https://github.com/berlindb/core/issues)[2 PRs](https://github.com/berlindb/core/pulls)7MITPHPPHP &gt;=8.1CI passing

Since Jul 12Pushed 2w ago17 watchersCompare

[ Source](https://github.com/berlindb/core)[ Packagist](https://packagist.org/packages/berlindb/core)[ Docs](https://github.com/berlindb/core)[ RSS](/packages/berlindb-core/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (5)Dependencies (9)Versions (11)Used By (7)

BerlinDB
========

[](#berlindb)

[![CI](https://github.com/berlindb/core/actions/workflows/ci.yml/badge.svg)](https://github.com/berlindb/core/actions/workflows/ci.yml)[![Packagist Version](https://camo.githubusercontent.com/e0bf4ec1751b2afccd085ba497e204edbe1f784b41faea73594fedfd545d3fe3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6265726c696e64622f636f72652e737667)](https://packagist.org/packages/berlindb/core)[![PHP Version](https://camo.githubusercontent.com/26aef83b3ffe74ce930817030899716a76cbd541fa811dcf9a9cc9c6729c488c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6265726c696e64622f636f72652f7068702e737667)](https://packagist.org/packages/berlindb/core)[![License](https://camo.githubusercontent.com/90a4ff929f098b138b0a0938dd09fc760a3a54d745023743f3c0556ada00df6b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6265726c696e64622f636f72652e737667)](LICENSE)

[![EDD](https://camo.githubusercontent.com/d9cc1a3fc2ab8a2feb7104660349646927970fb7c1886159aeb135c41ec2ffa2/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6265726c696e64622f6564642d636f72652d7461626c65732f6d61737465722f2e72656164696e6573732f6564642e6a736f6e266c6162656c3d454444)](https://github.com/berlindb/edd-core-tables)[![Sugar Calendar](https://camo.githubusercontent.com/65ff1a8c7f69f16d0d0e0dbead764ed791905894d92ac159632437430e9896fe/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6265726c696e64622f73632d636f72652d7461626c65732f6d61737465722f2e72656164696e6573732f73756761722d63616c656e6461722e6a736f6e266c6162656c3d537567617225323043616c656e646172)](https://github.com/berlindb/sc-core-tables)[![WordPress](https://camo.githubusercontent.com/f4b815a91369e119d0fc00fd6cb50c27c0244e438e7f44cf63713726397ffe9a/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6265726c696e64622f77702d636f72652d7461626c65732f6d61737465722f2e72656164696e6573732f776f726470726573732e6a736f6e266c6162656c3d576f72645072657373)](https://github.com/berlindb/wp-core-tables)[![WooCommerce](https://camo.githubusercontent.com/cbc2f5fce41ba2ba6b32bcbbccb648ca0be65ff7811c7fcf61ca51bbd833d537/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6265726c696e64622f77632d636f72652d7461626c65732f6d61737465722f2e72656164696e6573732f776f6f636f6d6d657263652e6a736f6e266c6162656c3d576f6f436f6d6d65726365)](https://github.com/berlindb/wc-core-tables)

BerlinDB provides an ORM-like interface for custom database tables in WordPress.

Use it when custom post types, taxonomies, or post meta are no longer the right storage model for your data, but you still want a WordPress-native developer experience: `wpdb` compatibility, schema objects, query builders, row objects, caching hooks, and table upgrade routines.

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

[](#requirements)

- PHP 8.1 or newer
- WordPress
- Composer
- MySQL 5.7+ or MariaDB 10.2+

BerlinDB generates MySQL/MariaDB-flavored SQL. The supported floor is **MySQL 5.7**or **MariaDB 10.2** (the baseline for the row-constructor `IN` and related SQL it emits); CI runs the suite against both engines at that floor and at a current release (MySQL 8.4, MariaDB 11.4). Older engines and other databases (PostgreSQL, SQLite, ...) are not supported.

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

[](#installation)

```
composer require berlindb/core
```

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

[](#quick-start)

A typical integration defines four small classes:

- a `Schema` that describes columns and indexes
- a `Table` that creates and upgrades the database table
- a `Row` that shapes returned records
- a `Query` that reads and writes records

### Define A Schema

[](#define-a-schema)

```
