PHPackages                             mikehenrty/thin-pdo-wrapper - 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. mikehenrty/thin-pdo-wrapper

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

mikehenrty/thin-pdo-wrapper
===========================

A simple database abstraction for using PDO with MySQL, Postgres, and SQLite.

1.0.1(9y ago)68551↓100%31[2 issues](https://github.com/mikehenrty/thin-pdo-wrapper/issues)MITPHPPHP &gt;=5.3.0

Since Apr 27Pushed 9y ago11 watchersCompare

[ Source](https://github.com/mikehenrty/thin-pdo-wrapper)[ Packagist](https://packagist.org/packages/mikehenrty/thin-pdo-wrapper)[ Docs](https://github.com/mikehenrty/thin-pdo-wrapper)[ RSS](/packages/mikehenrty-thin-pdo-wrapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Thin PDO Wrapper
================

[](#thin-pdo-wrapper)

A simple database client utilizing PHP PDO.

Advantages
----------

[](#advantages)

- Maintains at most one connection to slave DB and one to master DB per request.
- Automatically uses slave connection for data retrieval, master for writes.
- Randomized slave connection, with automatic fallback to master if no slaves exist.
- Enforces data sanitization (using PDO prepared statements and bind parameters).
- Catches all errors, and writes them to error log if configured to do so.
- Automatic timestamps for creates and updates
- Handles multiple inserts with a single query.
- Fallback to custom queries if one needs to do a join or second order query.
- Deals exclusively with associative arrays for input/output

Configuration
-------------

[](#configuration)

### Master

[](#master)

```
  $pdo->configMaster(
    'myhostname.example',
    'my_database_name',
    'my_database_user',
    'my_database_password',
    'my_database_port' // optional
  );

```

### Slaves (optional)

[](#slaves-optional)

```
  $pdo->configSlave(
    'myhostname1.example',
    'my_database_name',
    'my_database_user',
    'my_database_password',
    'my_database_port' // optional
  );

  $pdo->configSlave(
    'myhostname2.example',
    'my_database_name',
    'my_database_user',
    'my_database_password',
    'my_database_port' // optional
  );
  // etc

```

Examples
--------

[](#examples)

### Selecting

[](#selecting)

```
  $results = PDOWrapper::instance()->select('post', array('thread_id'=>$thread_id));
  $results = PDOWrapper::instance()->select('thread', array('open'=>0), $limit+1, $start, array('favs'=>'DESC'));

```

### Inserting

[](#inserting)

```
  $invite_id = PDOWrapper::instance()->insert('invite', array(
    'user_id' => $user_id,
    'text' => $text,
    'invite_key' => $invite_key
  ));

```

### Complex Queries with bind parameters

[](#complex-queries-with-bind-parameters)

```
  $post = PDOWrapper::instance()->queryFirst('
    SELECT invite.*, user.name FROM invite
    LEFT JOIN user ON user.id=invite.user_id
    WHERE invite_key=:invite_key
  ', array(':invite_key'=>$invite_key));

```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.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 ~1194 days

Total

2

Last Release

3565d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b6f1062251deb440edeb5ec98c500a28f3232fdb6b988bae4045bdc5e3a2dc0c?d=identicon)[mikehenrty](/maintainers/mikehenrty)

---

Top Contributors

[![mikehenrty](https://avatars.githubusercontent.com/u/635365?v=4)](https://github.com/mikehenrty "mikehenrty (10 commits)")[![tohir](https://avatars.githubusercontent.com/u/51109?v=4)](https://github.com/tohir "tohir (1 commits)")

---

Tags

databasemysqlsqlitepostgrespdowrapperdbthin

### Embed Badge

![Health badge](/badges/mikehenrty-thin-pdo-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/mikehenrty-thin-pdo-wrapper/health.svg)](https://phpackages.com/packages/mikehenrty-thin-pdo-wrapper)
```

###  Alternatives

[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)[atlas/query

Object-oriented query builders and performers for MySQL, Postgres, SQLite, and SQLServer.

41249.0k6](/packages/atlas-query)[aura/sqlschema

Provides facilities to read table names and table columns from a database using PDO.

41234.1k4](/packages/aura-sqlschema)

PHPackages © 2026

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