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

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

phpnomad/db
===========

3.0.1(3w ago)05.4k↓22.1%[3 PRs](https://github.com/phpnomad/db/pulls)7MITPHPCI failing

Since Jun 19Pushed 3w ago2 watchersCompare

[ Source](https://github.com/phpnomad/db)[ Packagist](https://packagist.org/packages/phpnomad/db)[ Docs](https://github.com/phpnomad/core)[ RSS](/packages/phpnomad-db/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (26)Versions (28)Used By (7)

phpnomad/db
===========

[](#phpnomaddb)

[![Latest Version](https://camo.githubusercontent.com/529d7244c5c6faf4246873da2d76b982cb32e4163605dd43c3bf1d1c7ddacb82/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068706e6f6d61642f64622e737667)](https://packagist.org/packages/phpnomad/db)[![Total Downloads](https://camo.githubusercontent.com/65dcaea14d0c6c277a2ba7531531c38bb52432f715965dd1957694d12139d75c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068706e6f6d61642f64622e737667)](https://packagist.org/packages/phpnomad/db)[![PHP Version](https://camo.githubusercontent.com/2298cd1bf31070c86cde3f17043201d74dbe1533dbff0a7aa5018778ff0ffa81/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068706e6f6d61642f64622e737667)](https://packagist.org/packages/phpnomad/db)[![License](https://camo.githubusercontent.com/74e6fa6d91e201be545f27f6984d68001d05d33252ee2258215b172792fa038b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068706e6f6d61642f64622e737667)](https://packagist.org/packages/phpnomad/db)

`phpnomad/db` implements the datastore pattern for SQL databases. It gives you table schemas, query building, automatic caching, and event broadcasting on top of the storage-agnostic abstractions in `phpnomad/datastore`, so your handlers stay free of raw SQL and your domain logic stays portable.

You get full CRUD operations, condition-array querying, cache lookups on reads, cache invalidation on writes, and `RecordCreated`, `RecordUpdated`, and `RecordDeleted` events dispatched from every mutation. The package powers the data layer in [Siren](https://sirenaffiliates.com) and has been in production for years.

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

[](#installation)

```
composer require phpnomad/db
```

This package is the abstraction layer. To actually execute queries you also need a concrete integration like `phpnomad/mysql-db-integration`, which provides the `QueryStrategy` and table-management strategies that `phpnomad/db` delegates to.

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

[](#quick-start)

Define a table schema by extending `Table`. Columns and indices come from value objects and factories, and a table version string lets migrations detect schema changes.

```
