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

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

igorv/database
==============

Simple database querybuilder for PDO.

v1.1.0(9y ago)024MITPHP

Since Jun 1Pushed 8y agoCompare

[ Source](https://github.com/uglypony/Database)[ Packagist](https://packagist.org/packages/igorv/database)[ RSS](/packages/igorv-database/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

PDO Query builder
=================

[](#pdo-query-builder)

Perform install using composer:

`composer require igorv/database`

Configuration in your bootstrap file:

```
require 'vendor/autoload.php';

use IgorV\Database\DB;

DB::config([
    'dsn'      => 'mysql:host=localhost;dbname=example',
    'username' => 'username',
    'password' => 'password',
    'options'  => [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
]);
```

DB can now be accessed using the DB static class.

Usage
-----

[](#usage)

To use the query builder, call table() method containing the table your wish to query followed by other methods needed to build your query.

Select queries can be performed by appending either first() or get() method. first() returns the first record as a ResultSet object. get() returns a Collection object with the ResultsSet objects.

```
$user = DB::table('users')->where('id', 1)->first();

$posts = DB::table('posts')->where('visible', true)->get();
```

To inject query results into a different class use the as() method:

```
$user = DB::table('users')->sortBy('created_at', 'desc')->as(User::class)->first();
```

Inserting database records is done by appending insert() method at the end. Returns the number of rows affected:

```
$inserted = DB::table('users')->insert([
    'user'      => $user,
    'password'  => $password,
    'active'    => true
]);
```

Updating records is done by appending update() method. Returns the number of affected rows:

```
$updated = DB::table('users')->where('id', $id)->update([
    'name'  => 'John Doe',
    'age'   => 41
]);
```

Deleting records is done by appending delete() method. Returns the number of affected rows:

```
$deleted = DB::table('users')->where('age', '>', '10')->delete();
```

Counting records can be done by appending count() method. Returns the number of rows matching your query:

```
$number = DB::table('users')->where('active', true)->count();
```

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity66

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

Total

4

Last Release

3358d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/770858?v=4)[igorv](/maintainers/igorv)[@igorv](https://github.com/igorv)

---

Top Contributors

[![ivalkenburg](https://avatars.githubusercontent.com/u/4926111?v=4)](https://github.com/ivalkenburg "ivalkenburg (7 commits)")

### Embed Badge

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

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

###  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)
