PHPackages                             itlessons/php-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. [Database &amp; ORM](/categories/database)
4. /
5. itlessons/php-database

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

itlessons/php-database
======================

PHP Database

0.0.1(11y ago)08411MITPHPPHP &gt;=5.4.0

Since Jan 9Pushed 11y ago1 watchersCompare

[ Source](https://github.com/itlessons/php-database)[ Packagist](https://packagist.org/packages/itlessons/php-database)[ Docs](https://github.com/itlessons/php-database)[ RSS](/packages/itlessons-php-database/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (1)

PHP Database
------------

[](#php-database)

Very simple database toolkit for PHP, providing simple pdo wrapper connection and query builder. It currently supports MySQL. Сreated for the study. But you can use it in real projects. Сode taken from Laravel Database Layer and simplified.

### Usage

[](#usage)

First, create a new manager instance.

```
use Database\Manager;

$manager = new Manager;

$manager->addConnection([
    'dsn' => 'mysql:dbname=testdb;host=127.0.0.1',
    'username' => 'root',
    'password' => null,
    'options' => [] // pdo driver options
]);
```

Once the Manager instance has been registered. You may use it like so:

**Using Connection**

```
$conn = $manager->getConnection();
$data = $conn->queryAll('select * from users where id in (?,?,?)', 1, 2, 3);
// $data -> [['id' => 1, 'name' => 'joe'], ...]

$conn->exec('insert into users (id, name) values (?, ?)', 1, 'joe'));

$conn->execBatch(file_get_contents('file_with_queries.txt'));
```

**Using The Query Builder**

```
$data = $manager
            ->query('users')
            ->select('*')
            ->whereIn('id', [1,2,3])
            ->execute();

// $data -> [['id' => 1, 'name' => 'joe'], ...]

$data = $manager
            ->query('users')
            ->update(['votes' => 2])
            ->where('id', 1)
            ->toSql();
// $data -> ['update `user` set `votes` = ? where `id` = ?',[2,1]]

$data = $manager
          ->query('users')
          ->insert([
              ['email' => 'john@example.com', 'votes' => 0],
              ['email' => 'john1@example.com', 'votes' => 1]
          ])->execute();
```

More about query builder see in [QueryBuilderTest](https://github.com/itlessons/php-database/blob/master/tests/Database/Tests/QueryBuilderTest.php)

### Installation

[](#installation)

The recommended way to install php-database is through [Composer](http://getcomposer.org). Just create a `composer.json` file and run the `php composer.phar install` command to install it:

```
{
    "require": {
        "itlessons/php-database": "*"
    }
}

```

Alternatively, you can download the [php-database.zip](https://github.com/itlessons/php-database/archive/master.zip) file and extract it.

### Resources

[](#resources)

You can run the unit tests with the following command:

```
$ cd path/to/php-database/
$ composer.phar install
$ phpunit

```

### Links

[](#links)

- [MySQL библиотека на сайте с помощью PHP](http://www.itlessons.info/php/database-mysql/)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

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

4143d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7283c22f1b152268a8a17acd947f00c4f65f41401a34407f2319de57cca45fb8?d=identicon)[itlessons](/maintainers/itlessons)

---

Top Contributors

[![itlessons](https://avatars.githubusercontent.com/u/5404185?v=4)](https://github.com/itlessons "itlessons (9 commits)")

---

Tags

databasemysqlquery builderitlessons

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[cycle/database

DBAL, schema introspection, migration and pagination

64690.9k31](/packages/cycle-database)[opis/database

A database abstraction layer over PDO, that provides a powerful and intuitive query builder, bundled with an easy to use schema builder

10184.2k3](/packages/opis-database)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)

PHPackages © 2026

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