PHPackages                             victorvolpe/php-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. victorvolpe/php-pdo-wrapper

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

victorvolpe/php-pdo-wrapper
===========================

A modern PDO wrapper for PHP 8.2+, supporting dynamic placeholders and secure database access.

v1.0.0(1y ago)14MITPHPPHP &gt;=8.2

Since Apr 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/VictorVolpe/PHP-PDO-Wrapper)[ Packagist](https://packagist.org/packages/victorvolpe/php-pdo-wrapper)[ RSS](/packages/victorvolpe-php-pdo-wrapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

PHP-PDO-Wrapper
===============

[](#php-pdo-wrapper)

A simple, modern, and lightweight PHP PDO wrapper for MySQL (and compatible databases). Built with type safety, PSR standards, and inspired by [lincanbin/PHP-PDO-MySQL-Class](https://github.com/lincanbin/PHP-PDO-MySQL-Class).

Features
--------

[](#features)

- Easy database connections with automatic retry
- Secure query binding (including `IN (?)` arrays support)
- Fluent methods for common operations (select, insert, update, delete)
- Transaction support
- Error handling with automatic reconnection on server timeout
- Simple logging for connection and query errors

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

[](#installation)

You can install via Composer:

```
composer require victorvolpe/php-pdo-wrapper

```

Or simply include `DB.php` manually if you prefer not to use Composer.

Usage
-----

[](#usage)

### 1. Instantiate the Database

[](#1-instantiate-the-database)

```
use VictorVolpe\PhpPdoWrapper\DB;

$db = new DB(
    dsn: 'mysql:host=localhost;dbname=testdb;charset=utf8mb4',
    user: 'your_username',
    pass: 'your_password'
);
```

### 2. Basic Query

[](#2-basic-query)

```
$users = $db->query("SELECT * FROM users WHERE status = :status", [
    'status' => 'active'
]);
```

### 3. Fetch a Single Row

[](#3-fetch-a-single-row)

```
$user = $db->row("SELECT * FROM users WHERE id = :id", [
    'id' => 1
]);
```

### 4. Fetch a Single Column

[](#4-fetch-a-single-column)

```
$emails = $db->column("SELECT email FROM users WHERE status = :status", [
    'status' => 'active'
]);
```

### 5. Fetch a Single Value

[](#5-fetch-a-single-value)

```
$email = $db->single("SELECT email FROM users WHERE id = :id", [
    'id' => 1
]);
```

### 6. Insert a New Record

[](#6-insert-a-new-record)

```
$newUserId = $db->insert('users', [
    'username' => 'newuser',
    'email' => 'newuser@example.com',
    'status' => 'active'
]);
```

### 7. Update Existing Records

[](#7-update-existing-records)

```
$rowsAffected = $db->update('users', [
    'status' => 'inactive'
], "last_login < :date", [
    'date' => '2024-01-01'
]);
```

### 8. Delete Records

[](#8-delete-records)

```
$rowsDeleted = $db->delete('users', "status = :status", [
    'status' => 'inactive'
]);
```

### 9. Transactions

[](#9-transactions)

```
$db->begin();

try {
    $db->query("UPDATE accounts SET balance = balance - :amount WHERE id = :id", [
        'amount' => 100,
        'id' => 1
    ]);

    $db->query("UPDATE accounts SET balance = balance + :amount WHERE id = :id", [
        'amount' => 100,
        'id' => 2
    ]);

    $db->commit();
} catch (Exception $e) {
    $db->rollback();
    throw $e;
}
```

Logging
-------

[](#logging)

If a connection error or query exception occurs, a log file will automatically be created in:

```
/logs/db-YYYY-MM-DD.log

```

License
-------

[](#license)

This project is open-sourced under the [MIT License](https://github.com/VictorVolpe/PHP-PDO-Wrapper/blob/master/LICENSE).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance48

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

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

384d ago

### Community

Maintainers

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

---

Tags

phpdatabasemysqlpdowrapperdb

### Embed Badge

![Health badge](/badges/victorvolpe-php-pdo-wrapper/health.svg)

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

###  Alternatives

[envms/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

925511.7k13](/packages/envms-fluentpdo)[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

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

An advanced, compact and lightweight MySQL database wrapper library, built around PHP's MySQLi extension.

11812.0k](/packages/stefangabos-zebra-database)[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)

PHPackages © 2026

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