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

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

monoclus/db
===========

A lightweight wrapper for PDO.

0.1(5y ago)04MITPHP

Since Oct 15Pushed 5y agoCompare

[ Source](https://github.com/monoclus/db)[ Packagist](https://packagist.org/packages/monoclus/db)[ RSS](/packages/monoclus-db/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (2)Used By (0)

MONOCLUS / DB
=============

[](#monoclus--db)

This is a lightweight wrapper for PDO. It is meant so solve some obvious gaps PDO has now. It is NOT a replacement for PDO.

Quick example:
--------------

[](#quick-example)

```
Connection::create()
    ->table('users')
    ->insert(['user_name'=>'tom',
              'first_name'=>'Tom',
              'last_name'=>'Sawyer']);

```

Obvious limitations
-------------------

[](#obvious-limitations)

- It is not an ORM. Should you need one, try [Doctrine](https://www.doctrine-project.org/).
- Version 0.1 only works with MySQL.
- It is not a replacement for PDO

Examples
--------

[](#examples)

### Connecting to the database

[](#connecting-to-the-database)

```
use monoclus\db

// Option 1: Create an object
$conn = new Connection($dsn, $user, $pass);

// Option 2: Use a builder
Connection::create($dsn, $user, $pass);

// Option 3: Create an object, but the parameters must be store in $_ENV
$conn = new Connection();

// Option 4: Use a builder with $_ENV parameters
Connection::create();

```

```
Connection::create()
    ->throwExceptionOnError()

```

### Insert

[](#insert)

```
Connection::create()
    ->table('users')
    ->insert(['user_name'=>'tom',
              'first_name'=>'Tom',
              'last_name'=>'Sawyer']);

```

### Update

[](#update)

```
Connection::create()
    ->table('users')
    ->filter(['id'=>4])
    ->update(['user_name'=>'tom',
              'first_name'=>'Tom',
              'last_name'=>'Sawyer']);

```

### Delete

[](#delete)

```
Connection::create()
    ->table('users')
    ->filter(['id'=>4])
    ->delete();

```

### All other cases

[](#all-other-cases)

Use the standard PDO functions and, ideally, thy to use prepared statements.

```
$sql = 'SELECT name, colour, calories
        FROM fruit
        WHERE calories < :calories AND colour LIKE :colour';
$sth = Connection::create()->prepare($sql);
$sth->bindParam(':calories', $calories, PDO::PARAM_INT);
$sth->bindValue(':colour', "%{$colour}%");
$sth->execute();

```

or, to update more records:

```
$sql = 'UPDATE fruit
        SET calories = :calories + 5
        WHERE colour = :colour';
$sth = Connection::create()->prepare($sql);
$sth->execute();

```

###  Health Score

20

—

LowBetter than 12% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Unknown

Total

1

Last Release

2132d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48e015d08e6b647eb3edc7d0f487df5bbafca80fa9a404731faa586379006cc7?d=identicon)[relu692](/maintainers/relu692)

---

Top Contributors

[![relu-dm](https://avatars.githubusercontent.com/u/51889524?v=4)](https://github.com/relu-dm "relu-dm (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/monoclus-db/health.svg)

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.8k117.8M121](/packages/jdorn-sql-formatter)[backup-manager/backup-manager

A framework agnostic database backup manager with user-definable procedures and support for S3, Dropbox, FTP, SFTP, and more with drivers for popular frameworks.

1.7k1.6M11](/packages/backup-manager-backup-manager)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M88](/packages/propel-propel1)[insolita/yii2-migration-generator

Set of gii tools for generating files for migration by schema of table , phpdoc or table data

108508.0k5](/packages/insolita-yii2-migration-generator)[xpdo/xpdo

A PDO-based Object/Relational Bridge Library

7088.4k4](/packages/xpdo-xpdo)[voku/session2db

A PHP library acting as a wrapper for PHP's default session handling functions which stores data in a MySQL database, providing both better performance and better security and protection against session fixation and session hijacking.

2920.0k](/packages/voku-session2db)

PHPackages © 2026

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