PHPackages                             trehinos/thor-pdo-extension - 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. trehinos/thor-pdo-extension

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

trehinos/thor-pdo-extension
===========================

A PDO extension for Thor

v1.0.6(7mo ago)1331MITPHPPHP ^8.2

Since Jan 30Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/Trehinos/thor-pdo-extension)[ Packagist](https://packagist.org/packages/trehinos/thor-pdo-extension)[ RSS](/packages/trehinos-thor-pdo-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (8)Used By (1)

Thor PDO Extension
==================

[](#thor-pdo-extension)

A tiny helper library around PHP's PDO to make connecting and running SQL easier, with a simple Criteria builder and small CRUD helper.

- Handler: lazy-connecting PDO wrapper
- Requester: execute parameterized queries conveniently
- Criteria: build WHERE clauses from arrays
- ArrayCrud: minimal CRUD for associative array rows
- PdoCollection: manage multiple connections

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

[](#installation)

Install via Composer:

```
composer require trehinos/thor-pdo-extension

```

Requires PHP 8.2+ and ext-pdo.

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

[](#quick-start)

Create a connection and run queries:

```
use Thor\Database\PdoExtension\Handler;
use Thor\Database\PdoExtension\Requester;

$handler = new Handler('sqlite::memory:');
$req = new Requester($handler);
$req->execute('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT NOT NULL)');
$req->execute('INSERT INTO users (name) VALUES (?)', ['Alice']);
$row = $req->request('SELECT * FROM users WHERE name = ?', ['Alice'])->fetch();
```

Build WHERE clauses with Criteria:

```
use Thor\Database\PdoExtension\Criteria;

$criteria = new Criteria([
    'company' => 'Xerox',
    'OR' => [
        'employee_id' => [1, 14, 999],
        'manager_id'  => 4,
    ],
]);
$sql    = Criteria::getWhere($criteria); // WHERE company = ? AND ("employee_id" IN (?,?,?) OR manager_id = ?)
$params = $criteria->getParams();        // ['Xerox', 1, 14, 999, 4]
```

Minimal CRUD with ArrayCrud:

```
use Thor\Database\PdoExtension\ArrayCrud;
use Thor\Database\PdoExtension\Criteria;

$crud = new ArrayCrud('users', ['id'], $req);
$crud->createOne(['id' => 1, 'name' => 'Alice']);
$user = $crud->readOne(['id' => 1]);
$crud->update(['name' => 'Alice Cooper'], new Criteria(['id' => 1]));
$crud->delete(new Criteria(['id' => 1]));
```

Manage multiple connections with PdoCollection:

```
use Thor\Database\PdoExtension\PdoCollection;
use Thor\Database\PdoExtension\Handler;

$pdos = (new PdoCollection())
    ->add('default', new Handler('sqlite::memory:'))
    ->add('analytics', new Handler('sqlite::memory:'));
$pdo = $pdos->get('default')?->getPdo();
```

Testing
-------

[](#testing)

This project uses PHPUnit 10. To run the test suite:

```
./vendor/bin/phpunit --colors=always

```

The tests use an in-memory SQLite database, so no external services are required.

License
-------

[](#license)

© 2023-2025 Sébastien Geldreich Distributed under the MIT License.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance65

Regular maintenance activity

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~103 days

Recently: every ~140 days

Total

7

Last Release

213d ago

### Community

Maintainers

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

---

Top Contributors

[![Trehinos](https://avatars.githubusercontent.com/u/3908278?v=4)](https://github.com/Trehinos "Trehinos (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/trehinos-thor-pdo-extension/health.svg)

```
[![Health](https://phpackages.com/badges/trehinos-thor-pdo-extension/health.svg)](https://phpackages.com/packages/trehinos-thor-pdo-extension)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M545](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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