PHPackages                             leven-framework/dba-common - 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. leven-framework/dba-common

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

leven-framework/dba-common
==========================

1.1.0(3y ago)0493PHP

Since Apr 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/leven-framework/dba-common)[ Packagist](https://packagist.org/packages/leven-framework/dba-common)[ RSS](/packages/leven-framework-dba-common/feed)WikiDiscussions master Synced today

READMEChangelog (2)DependenciesVersions (3)Used By (3)

Leven Database Adapter Interface
================================

[](#leven-database-adapter-interface)

Features
--------

[](#features)

- 🧪 abstract access to the database
- 🏗 simple query builder with nested conditions support
- 🔐 automatic escaping of table and column names and values

Usage examples
--------------

[](#usage-examples)

### Select

[](#select)

```
$result = $db->select('foo_table')
    ->columns('id', 'name') // optional, defaults to all columns
    ->where('id', '>', 1)->orWhere('age', '>', 22)
    ->orWhere(fn(\Leven\DBA\Common\BuilderPart\WhereGroup $w) => $w
        ->where('name', 'IN', ['Foo', 'Bar'])
        ->andWhere('description', 'LIKE', '%foo%')
    )
    ->orderDesc('id')->orderAsc('name')
    ->limit(1)->offset(1)
    ->execute();

foreach($result as $row) {} // you can iterate over the rows
$result->rows; // or access the rows as an array
$result->count; // count of rows returned
```

### Insert

[](#insert)

```
$result = $db->insert('foo_table', ['name' => 'Foo']);

$result->lastId; // last inserted id (auto increment) or null
```

### Update

[](#update)

```
$db->update('foo_table')
    ->set('name', 'Foo')
    ->where('id', '!=', 3)
    ->limit(10)
    ->execute();
```

### Delete

[](#delete)

```
$db->delete('foo_table')
    ->where('id', 5)
    ->limit(11)
    ->execute();
```

Implementations
---------------

[](#implementations)

### [📦 MySQL](https://github.com/leven-framework/dba-mysql)

[](#-mysql)

```
composer require leven-framework/dba-mysql
```

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

// all arguments are optional except for database
$db = new \Leven\DBA\MySQL\MySQLAdapter(
    database: 'example',
    user: 'username',
    password: 'password',
    host: 'localhost',
    port: 3306,
    charset: 'utf8',
    tablePrefix: 'prefix_'
);

// or use an existing PDO instance
$db = new \Leven\DBA\MySQL\MySQLAdapter($pdo);
```

### [📦 Mock](https://github.com/leven-framework/dba-mock)

[](#-mock)

```
composer require leven-framework/dba-mock
```

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

// saving and loading the database in JSON is slow but useful for development
$db = new \Leven\DBA\Mock\MockAdapter(
    fn() => json_decode(file_get_contents('db.json'), true),
    fn(\Leven\DBA\Mock\Structure\Database $db) => file_put_contents('db.json', json_encode($db->toArray(), JSON_PRETTY_PRINT))
);

// first argument can also be an array representing the database
$dbArray = [
    'foo_table' => [
        ['id' => 'int', 'name' => 'varchar'],
        [1, 'Foo'],
        [2, 'Bar'],
    ],
];
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity50

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

Every ~76 days

Total

2

Last Release

1452d ago

### Community

Maintainers

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

---

Top Contributors

[![leongrdic](https://avatars.githubusercontent.com/u/6260068?v=4)](https://github.com/leongrdic "leongrdic (10 commits)")

---

Tags

adapterdatabasedatabase-abstractiondatabase-layerdbadbalmockmysqlphpphp8

### Embed Badge

![Health badge](/badges/leven-framework-dba-common/health.svg)

```
[![Health](https://phpackages.com/badges/leven-framework-dba-common/health.svg)](https://phpackages.com/packages/leven-framework-dba-common)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M117](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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