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

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

h2lsoft/db-manager
==================

PDO wrapper to manage query

v1.3.0(3mo ago)0591MITPHP

Since Apr 21Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/h2lsoft/db-manager)[ Packagist](https://packagist.org/packages/h2lsoft/db-manager)[ RSS](/packages/h2lsoft-db-manager/feed)WikiDiscussions master Synced 1w ago

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

DB Manager
==========

[](#db-manager)

PDO wrapper to simplify db queries. It provides a simple way to create, retrieve, update &amp; delete records.

[![Version](https://camo.githubusercontent.com/c906d0496a01a29b5d1e13a3319e0af11d56b072f92d5ee4285c6f7487b50d6f/68747470733a2f2f62616467652e667572792e696f2f67682f68326c736f667425324664622d6d616e616765722e737667)](https://badge.fury.io/gh/h2lsoft%2Fdb-manager)

Requirements
------------

[](#requirements)

- php &gt;= 7.3
- php PDO extension

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

[](#installation)

Install directly via [Composer](https://getcomposer.org):

```
$ composer require h2lsoft/db-manager
```

Basic Usage
-----------

[](#basic-usage)

```
use \h2lsoft\DBManager;

$DBM = new DBManager\DBManager(); // soft mode is activated by default
$DBM->connect('mysql', 'localhost', 'root', '', 'mydatabase');

// execute simple query with binding
$sql = "SELECT Name, SurfaceArea FROM Country WHERE Continent = :Continent AND deleted = 'NO' ORDER BY SurfaceArea DESC LIMIT 3";
$results = $DBM->query($sql, [':Continent' =>  'Asia'])->fetchAll();

// or use short version
$sql = $DBM->select("Name, SurfaceArea")
           ->from('Country')
           ->where("Continent = :Continent")
           ->orderBy('SurfaceArea DESC')
           ->limit(3)
           ->getSQL();
$results = $DBM->query($sql, [':Continent' =>  'Asia'])->fetchAll();

// or imbricated version
$results = $DBM->select("Name, SurfaceArea")
                      ->from('Country')
                      ->where("Continent = :Continent")
                      ->orderBy('SurfaceArea DESC')
                      ->limit(3)
                      ->executeSql([':Continent' =>  'Asia'])
                            ->fetchAll();

// insert
$values = [];
$values['Name'] = "Agatha Christies";
$values['Birthdate'] = "1890-10-15";

$ID = $DBM->table('Author')->insert($values);

// update
$values = [];
$values['Name'] = "Agatha Christies";
$affected_rows = $DBM->table('Author')->update($values, $ID); # you can put direct ID or you can use where clause

// delete
$affected_rows = $DBM->table('Author')->delete(["ID = ?", $ID]);
```

Soft Mode
---------

[](#soft-mode)

Soft mode is activated by default, it allow to automatic timestamp and author on each record for operation like : `Insert`, `Update`, `Delete`. Soft mode is optional but recommended, you can disable it in constructor or you can use $DBM-&gt;SoftMode(0);

Soft mode allows you to keep data safe by turn flag field `deleted` to `yes` and no trash your record physically. It is useful to retrieve your data in case of accidentally delete rows.

You can use magic method `$DBM->table('my_table')->addSoftModeColumns()` this will add automatically soft mode columns :

- `deleted` (enum =&gt; yes, no)
- `created_at` (datetime)
- `created_by` (varchar)
- `updated_at` (datetime)
- `updated_by` (varchar)
- `deleted_at` (datetime)
- `deleted_by` (varchar)

Pagination component
--------------------

[](#pagination-component)

```
$sql = $DBM->select("*")
           ->from('Country')
           ->where("Continent = :Continent")
           ->getSQL();

$params = [':Continent' => 'Asia'];

$current_page = 1;

// return a complete array paginate
$pager = $DBM->paginate($sql, $params, $current_page, 20);
```

```
[
    [total] => 51,
    [per_page] => 20,
    [last_page] => 3,
    [current_page] => 1,
    [from] => 1,
    [to] => 20,
    [page_start] => 1,
    [page_end] => 3,
    [data] => [
                        ....
              ]
]

```

Useful methods
--------------

[](#useful-methods)

```
// get a record by ID, you can use multiple ID by array
$record = $DBM->table('Country')->getByID(10);

//  multiple ID
$records = $DBM->table('Country')->getByID([12, 10, 55]);
```

License
-------

[](#license)

MIT. See full [license](LICENSE).

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance82

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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 ~124 days

Recently: every ~473 days

Total

18

Last Release

101d ago

### Community

Maintainers

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

---

Top Contributors

[![h2lsoft](https://avatars.githubusercontent.com/u/959252?v=4)](https://github.com/h2lsoft "h2lsoft (48 commits)")

---

Tags

databasedbmysqlpaginationpdopdo-wrapperphpsqlphpdatabasemysqlsqlpdo

### Embed Badge

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

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

###  Alternatives

[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M69](/packages/ifsnop-mysqldump-php)[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

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

PHP version of mysqldump cli that comes with MySQL

35489.8k6](/packages/druidfi-mysqldump-php)[delight-im/db

Safe and convenient SQL database access in a driver-agnostic way

49156.8k7](/packages/delight-im-db)[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)[riverside/php-orm

PHP ORM micro-library and query builder

111.2k](/packages/riverside-php-orm)

PHPackages © 2026

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