PHPackages                             morris/dop - 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. morris/dop

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

morris/dop
==========

An immutable API on top of PDO to compose and execute SQL statements

0.4.0(6y ago)16480[4 issues](https://github.com/morris/dop/issues)MITPHPPHP &gt;=5.3.0

Since Oct 23Pushed 6y ago1 watchersCompare

[ Source](https://github.com/morris/dop)[ Packagist](https://packagist.org/packages/morris/dop)[ Docs](https://github.com/morris/dop)[ RSS](/packages/morris-dop/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (7)Dependencies (2)Versions (8)Used By (0)

DOP
===

[](#dop)

[![Build Status](https://camo.githubusercontent.com/a9fc1250e337c09006961e71f6d7086354740b4639d03a65ff89c9b730edf107/68747470733a2f2f7472617669732d63692e6f72672f6d6f727269732f646f702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/morris/dop)[![Test Coverage](https://camo.githubusercontent.com/c1a2aa49fe83cbf2ccf5abfdb41759d6f4bbb9e39b830a8344c7d74497fabca9/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6d6f727269732f646f702f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/morris/dop/coverage)

DOP is an immutable API on top of [PDO](http://php.net/manual/en/book.pdo.php)to compose and execute SQL statements.

- Extended parameters (`::param` and `??`) allow binding to arbitrary values like arrays, `null` and SQL fragments.
- Provides helpers for writing common queries, e.g. selects, inserts, updates, deletes.
- Tested with **SQLite, PostgreSQL, and MySQL.**

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

[](#installation)

DOP requires PHP &gt;= 5.3.0 and PDO. Install via [composer](https://getcomposer.org/):

```
composer require morris/dop
```

Usage
-----

[](#usage)

```
// Connect to a database
$pdo = new PDO('sqlite:blog.sqlite3');
$dop = new Dop\Connection($pdo);

// Find posts by author IDs using DOP parametrization
$authorIds = [1, 2, 3];
$orderByTitle = $dop('ORDER BY title ASC');
$posts = $dop(
    'SELECT * FROM post WHERE author_id IN (??) ??',
    [$authorIds, $orderByTitle]
)->fetchAll();

// Find published posts using DOP helpers for common queries
$posts = $dop->query('post')->where('is_published = ?', [1])->fetchAll();

// Get categorizations of posts using DOP's map function
$categorizations = $dop(
    'SELECT * FROM categorization WHERE post_id IN (??)',
    [$dop->map($posts, 'id')]
)->fetchAll();

// Find posts with more than 3 categorizations using a sub-query as a parameter
$catCount = $dop('SELECT COUNT(*) FROM categorization WHERE post_id = post.id');
$posts = $dop(
    'SELECT * FROM post WHERE (::catCount) >= 3',
    ['catCount' => $catCount]
)->fetchAll();
```

Internally, `??` and `::named` parameters are resolved before statement preparation. Note that due to the current implementation using regular expressions, you should *never* use quoted strings directly. Always use bound parameters.

Reference
---------

[](#reference)

See [API.md](API.md) for a complete API reference.

Contributors
------------

[](#contributors)

- [jayaddison](https://github.com/jayaddison)

Thanks!

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.1% 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 ~215 days

Recently: every ~318 days

Total

7

Last Release

2200d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5a8abc912c6edf7bd2c37c29dae5cf7d775cbd6df90601e262440e21448582af?d=identicon)[morris](/maintainers/morris)

---

Top Contributors

[![morris](https://avatars.githubusercontent.com/u/32837?v=4)](https://github.com/morris "morris (37 commits)")[![jayaddison](https://avatars.githubusercontent.com/u/55152140?v=4)](https://github.com/jayaddison "jayaddison (5 commits)")

---

Tags

immutablepdophpsqldatabasesqlpdodop

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/morris-dop/health.svg)

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

###  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)[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M69](/packages/ifsnop-mysqldump-php)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[paragonie/easydb

Easy-to-use database abstraction

744273.4k23](/packages/paragonie-easydb)[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k22.9k](/packages/clouddueling-mysqldump-php)[ezsql/ezsql

Advance database access library. Make interacting with a database ridiculously easy. An universal interchangeable CRUD system.

86946.7k](/packages/ezsql-ezsql)

PHPackages © 2026

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