PHPackages                             mac/database - 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. mac/database

ActiveLibrary

mac/database
============

Simple PDO helper to perform most common database operations

1.2.2(12y ago)032MITPHP

Since Nov 8Pushed 12y ago1 watchersCompare

[ Source](https://github.com/mac2000/database)[ Packagist](https://packagist.org/packages/mac/database)[ RSS](/packages/mac-database/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (4)Dependencies (4)Versions (6)Used By (0)

Database PDO Helper
===================

[](#database-pdo-helper)

[![Build Status](https://camo.githubusercontent.com/3c490fb163690b1976b0247378af3bf431c852cff816161eabc7f4237445faf3/68747470733a2f2f7472617669732d63692e6f72672f6d6163323030302f64617461626173652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/mac2000/database)

PDO Helper implements some common database operations

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

[](#installation)

Here is `composer.json` example:

```
{
    "require": {
        "mac/database": "x"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/mac2000/database"
        }
    ]
}

```

Usage example
-------------

[](#usage-example)

First of all you need some database connection:

```
$db = new Database(new PDO('mysql:host=localhost;dbname=example', 'root', 'root'));
// or for test purposes
$db = new Database(new PDO('sqlite::memory:'));

```

Retrieve all/one row(s):

```
$users = $db->all("SELECT * FROM users");
$user = $db->one("SELECT * FROM users WHERE user_id = :user_id", array('user_id' => 1));

```

Retrieve computed value:

```
$count = $db->cell("SELECT COUNT(*) FROM users");

```

Modify data:

```
$lastInsertId = $db->execute(
    "INSERT INTO users (first_name, last_name, age) VALUES(:first_name, :last_name, :age)",
    array('first_name' => 'Hello', 'last_name' => 'World', 'age' => 9)
);

$rowsAffectedCount = $db->execute(
    "DELETE FROM users WHERE user_id = :user_id",
    array('user_id' => 2)
);

```

Run tests
---------

[](#run-tests)

Look at `.travis.yml` there is few tests that are runned:

```
vendor/bin/phpunit
vendor/bin/phpcpd src tests
vendor/bin/phpmd src,tests text cleancode, codesize, controversial, design, naming, unusedcode
vendor/bin/phpcs --standard=psr2 src tests

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

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

Total

5

Last Release

4443d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/584d9123f394548ae52dace4188a80ab5c3695f481271cf859ad26a94b86e021?d=identicon)[mac2000](/maintainers/mac2000)

---

Top Contributors

[![marchenko1985](https://avatars.githubusercontent.com/u/88868?v=4)](https://github.com/marchenko1985 "marchenko1985 (17 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/mac-database/health.svg)

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

PHPackages © 2026

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