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

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

eznio/db
========

DB Collections library inspired by Laravel

1.0.7(9y ago)043MITPHPPHP &gt;=5.4.0

Since Jul 21Pushed 9y ago1 watchersCompare

[ Source](https://github.com/eznio/db)[ Packagist](https://packagist.org/packages/eznio/db)[ Docs](https://github.com/eznio/sqlite-collections)[ RSS](/packages/eznio-db/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (6)Versions (9)Used By (0)

ezn.io\\db
==========

[](#ezniodb)

DB Entity Collections library inspired by Laravel

Quickstart
----------

[](#quickstart)

```
// Initializing database-specific driver
$driver = new \eznio\db\drivers\Sqlite('db/test.sqlite3');

// Creating Entity Manager
$em = new \eznio\db\EntityManager($driver);

// Getting query repository by table name
$repo = $em->getRepository('test');

// Getting ActiveRecord entity of table row with id = 1
$entity =$repo->findOneById(1);

// Updating and saving entity
$entity->field = 'new value';
$entity->save();
```

More details
------------

[](#more-details)

### Supported RDBMS

[](#supported-rdbms)

SQLite and MySQL for now.

### Error handling

[](#error-handling)

Especially designed to be silent, no internal exceptions. Functions return `null`/`[]` if anything happens.

### Placeholders basics

[](#placeholders-basics)

Several driver's functions accept second parameter called `$args`. This is list of placeholder values. Library is using PDO placeholders syntax, so we have 2 options:

- use `?` as placeholder name and provide simple list of substitutions:

    ```
    $driver->query(
        'SELECT * FROM USERS WHERE name = ? AND age = ?',
        ['John', 26]
    );
    ```

    In this case, substitutions order should be the same as in query.
- use `:named:` placeholders:

    ```
    $driver->query(
        'SELECT * FROM USERS WHERE name = :name: AND age = :age:',
        ['age' => 26, 'name' => 'John']
    );
    ```

    Named substitutions can be passed in any order.

Reference
---------

[](#reference)

### Driver

[](#driver)

Driver is DB-specific request handling class. Implements the `\eznio\db\drivers\Driver` interface.

#### query()

[](#query)

```
public function query($sql, array $args = []);
```

Runs SQL query and doesn't return anything. Useful for system queries like "SET NAMES" or similar.

```
$driver->query("SET NAMES :encoding:", ['encoding' => 'UTF-8'];
```

#### select()

[](#select)

```
public function select($sql, array $args = []);
```

Runs SQL query and returns produced result as array.

```
$result => $driver->select("SELECT * FROM users WHERE name = ?", ['John']);

/*  $result = [
 *      ['id' => 1, 'name' => 'John', 'surname' => 'Smith'],
 *      ['id' => 2, 'name' => 'John', 'surname' => 'Doe']
 */ ];
```

If `ARRAY_KEY` alias exists in resulting set - it's value will be added as array keys (and removed from resulting rows):

```
$result => $driver->select("SELECT id AS ARRAY_KEY, * FROM users WHERE name = ?", ['John']);

/*  $result = [
 *      1 => ['name' => 'John', 'surname' => 'Smith'],
 *      2 => ['name' => 'John', 'surname' => 'Doe']
 */ ];
```

#### getRow()

[](#getrow)

```
public function getRow($sql, array $args = []);
```

Runs SQL query and returns produced its first row as array.

```
$result => $driver->getRow("SELECT * FROM users WHERE name = ?", ['John']);
```

#### getColumn()

[](#getcolumn)

```
public function getColumn($sql, array $args = []);
```

Runs SQL query and returns produced its first column as array of one-element arrays.

```
$result => $driver->getColumn("SELECT id FROM users WHERE name = ?", ['John']);

/*  $result = [
 *      1,
 *      2
 */ ];
```

`ARRAY_KEY` alias also works here:

```
$result => $driver->getColumn("SELECT id AS ARRAY_KEY, surname FROM users WHERE name = ?", ['John']);

/*  $result = [
 *      1 => 'Smith',
 *      2 => 'Doe'
 */ ];
```

#### getCell()

[](#getcell)

```
public function getCell($sql, array $args = []);
```

Runs SQL query and returns produced its first column of its first row:

```
$result => $driver->getCell("SELECT COUNT(*) FROM users WHERE name = ?", ['John']);

//  $result = 2;
```

#### load()

[](#load)

```
public function load($table, $id);
```

Shortcut to get values of a single row from given table by id:

```
$result => $driver->load('users', 1);

//  $result = ['id' => 1, name' => 'John', 'surname' => 'Smith'];
```

#### insert()

[](#insert)

```
public function insert($table, array $data);
```

Inserts data into the table and returns inserted ID

```
$result => $driver->insert('users', [
    'name' => 'John',
    'surname' => 'McKey'
]);

//  $result = 3;
```

#### update()

[](#update)

```
public function update($table, $id, $data);
```

Updates existing data by row ID:

```
$driver->update('users', [
    'name' => 'Mike',
], 1);
```

#### delete()

[](#delete)

```
public function delete($table, $id);
```

Deletes row with given ID:

```
$driver->delete('users', 3);
```

### Entity

[](#entity)

### Collection

[](#collection)

### EntityManager

[](#entitymanager)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

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

Recently: every ~23 days

Total

8

Last Release

3402d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d81a9338efaa22b0fd0e98575091f89f86190ab34354e3a555655a7b5a2a6f75?d=identicon)[evgeny-zinder](/maintainers/evgeny-zinder)

---

Top Contributors

[![evgeny-zinder](https://avatars.githubusercontent.com/u/6049024?v=4)](https://github.com/evgeny-zinder "evgeny-zinder (19 commits)")

---

Tags

mysqlsqlitecollections

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k605.0M6.7k](/packages/doctrine-dbal)[catfan/medoo

The lightweight PHP database framework to accelerate development

5.0k1.6M203](/packages/catfan-medoo)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58825.9M52](/packages/scienta-doctrine-json-functions)[nette/database

💾 Nette Database: layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.

5687.0M261](/packages/nette-database)[fresh/doctrine-enum-bundle

Provides support of ENUM type for Doctrine2 in Symfony applications.

4747.0M12](/packages/fresh-doctrine-enum-bundle)[cycle/orm

PHP DataMapper ORM and Data Modelling Engine

1.3k888.3k77](/packages/cycle-orm)

PHPackages © 2026

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