PHPackages                             decmuc/pdodb - 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. decmuc/pdodb

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

decmuc/pdodb
============

Modern, secure and fully compatible PDO-based replacement for ThingEngineer’s PHP-MySQLi-Database-Class

v1.4.0(1mo ago)8213↓92.2%2MITPHPPHP &gt;=8.1

Since Jul 2Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/decMuc/PDOdb)[ Packagist](https://packagist.org/packages/decmuc/pdodb)[ RSS](/packages/decmuc-pdodb/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)DependenciesVersions (18)Used By (0)

PDOdb – A Secure MySQL Query Builder for PHP 8+
===============================================

[](#pdodb--a-secure-mysql-query-builder-for-php-8)

PDOdb is a modern database wrapper built on top of PDO. It gives you a clean, expressive API for building queries without writing raw SQL by hand – while staying safe, strict and fast by default.

Inspired by [ThingEngineer/MySQLiDb](https://github.com/ThingEngineer/MysqliDb), but rewritten from scratch for PDO with full type-safe WHERE methods, strict injection protection and a fluent or step-by-step API – your choice.

📘 **Documentation:**

---

Why PDOdb?
----------

[](#why-pdodb)

Because writing `$pdo->prepare("SELECT...")` for the hundredth time is boring – and forgetting to bind a parameter is how things go wrong.

PDOdb handles the boring parts. You write what you mean:

```
$user = $db->whereInt('id', 42)->getOne('users');
// → SELECT * FROM users WHERE id = 42 LIMIT 1
```

No manual prepare, no manual bind, no white screen on error. Exceptions all the way.

---

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

[](#installation)

```
composer require decmuc/pdodb
```

Or [download manually](https://github.com/decMuc/PDOdb/releases/latest) – PDOdb is a single file.

---

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

[](#quick-start)

```
require 'vendor/autoload.php';
use decMuc\PDOdb\PDOdb;

$db = new PDOdb([
    'host'     => 'localhost',
    'username' => 'root',
    'password' => 'secret',
    'db'       => 'my_database',
    'charset'  => 'utf8mb4',
]);
```

Both styles work – use whichever fits your code:

```
// Step by step – easy to read and extend
$db->whereInt('active', 1);
$db->whereString('role', 'admin');
$db->orderBy('created_at', 'DESC');
$users = $db->get('users');

// Fluent – compact for experienced devs
$users = $db->whereInt('active', 1)
            ->whereString('role', 'admin')
            ->orderBy('created_at', 'DESC')
            ->get('users');

// → SELECT * FROM users WHERE active = 1 AND role = 'admin' ORDER BY created_at DESC
```

---

Features
--------

[](#features)

- ✅ **Type-safe WHERE methods** – `whereInt()`, `whereFloat()`, `whereString()`, `whereBool()`, `whereDate()`, `whereLike()`, `whereSoundsLike()` and more
- ✅ **Prepared statements** – all values are bound automatically, never interpolated
- ✅ **Heuristic injection check** – blocks obvious attack patterns like `1 OR 1=1` before they even reach the DB
- ✅ **Fluent or step-by-step API** – both work, both produce the same SQL
- ✅ **WHERE grouping** – `whereGroup()` for parenthesized conditions
- ✅ **Joins &amp; subqueries** – with prefix support and aliasing
- ✅ **Transactions** – `startTransaction()`, `commit()`, `rollback()`
- ✅ **Bulk insert &amp; pagination** – `insertBulk()`, `paginate()`
- ✅ **Table prefix** – set once, applied everywhere automatically
- ✅ **Multiple instances** – connect to several databases side by side
- ✅ **Named placeholders** in `rawQuery()` – both `:name` and `name` style
- ✅ **Debug &amp; trace** – `setTrace(true)`, `getLastDebugQuery()`, debug levels 0–3

---

A Few More Examples
-------------------

[](#a-few-more-examples)

```
// Boolean flags – the clean way
$db->whereBool('is_active', true)->get('users');
// → SELECT * FROM users WHERE is_active = 1

// Date range
$db->whereDateBetween('created_at', '2025-01-01', '2025-12-31')->get('orders');
// → SELECT * FROM orders WHERE created_at BETWEEN '2025-01-01' AND '2025-12-31'

// LIKE with wildcard modes
$db->whereLike('name', 'john', 'both')->get('users');
// → SELECT * FROM users WHERE name LIKE '%john%'

// WHERE groups with parentheses
$db->whereInt('active', 1)
   ->whereGroup(function($q) {
       $q->whereString('role', 'admin')
         ->orWhereString('role', 'editor');
   })
   ->get('users');
// → SELECT * FROM users WHERE active = 1 AND (role = 'admin' OR role = 'editor')

// Raw query with named placeholders
$db->rawQuery("SELECT * FROM users WHERE id = :id AND role = :role", [
    'id'   => 42,
    'role' => 'admin',
]);

// Insert & get ID
$id = $db->insert('users', [
    'name'  => 'Alice',
    'email' => 'alice@example.com',
    'active' => 1,
]);

// Transactions
$db->startTransaction();
try {
    $db->insert('orders', ['user_id' => 1, 'total' => 49.99]);
    $db->update('users', ['last_order' => date('Y-m-d')], $db->whereInt('id', 1));
    $db->commit();
} catch (\Throwable $e) {
    $db->rollback();
}
```

---

Error Handling
--------------

[](#error-handling)

PDOdb throws real exceptions – no more white screens, no more silent failures.

```
try {
    $db->whereInt('id', 'not-a-number');
    $user = $db->getOne('users');
} catch (\InvalidArgumentException $e) {
    echo $e->getMessage();
    // → Invalid integer value for column 'id'.
}
```

---

Roadmap
-------

[](#roadmap)

**v1.4.0** *(current)*

- `whereLike()` / `whereNotLike()` with wildcard modes (`both`, `left`, `right`, `none`)
- `whereSoundsLike()` using MySQL `SOUNDS LIKE`
- `whereGroup()` / `openWhereGroup()` / `closeWhereGroup()` for parenthesized conditions
- Named placeholders in `rawQuery()`
- Several bug fixes (JOIN prefix, subquery bind params, `copy()` with PDO)

**v2.0.0** *(planned)*

- Multi-driver support: **PostgreSQL**, **SQLite** (and later MSSQL)
- Same API, different dialects internally – your code stays the same
- Compatibility table per method in the docs (✅ MySQL ✅ PostgreSQL ⚠️ SQLite)

---

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

[](#documentation)

Full documentation with examples for every method: 👉 ****

---

License
-------

[](#license)

MIT – see [LICENSE](LICENSE) for details.

---

*Built with ❤️ by [L. Fischer (decMuc)](https://github.com/decMuc)*

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance90

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.9% 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 ~19 days

Recently: every ~74 days

Total

17

Last Release

52d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/63890391?v=4)[Lucky](/maintainers/decMuc)[@decMuc](https://github.com/decMuc)

---

Top Contributors

[![decMuc](https://avatars.githubusercontent.com/u/63890391?v=4)](https://github.com/decMuc "decMuc (91 commits)")[![xJuvi](https://avatars.githubusercontent.com/u/31671206?v=4)](https://github.com/xJuvi "xJuvi (1 commits)")

---

Tags

database-abstraction-layermysqlipdopdo-mysqlpdo-wrapperphp8query-builderreplacementwrapperdatabaseormpdowrappermysqlithingengineer

### Embed Badge

![Health badge](/badges/decmuc-pdodb/health.svg)

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

###  Alternatives

[sergeytsalkov/meekrodb

The Simple PHP/MySQL Library

346410.5k13](/packages/sergeytsalkov-meekrodb)[bephp/activerecord

micro activerecord library in PHP(only 400 lines with comments), support chain calls and relations(HAS\_ONE, HAS\_MANY, BELONGS\_TO).

1202.1k2](/packages/bephp-activerecord)[flightphp/active-record

Micro Active Record library in PHP, support chain calls, events, and relations.

164.0k11](/packages/flightphp-active-record)

PHPackages © 2026

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