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

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

flyokai/laminas-db
==================

Database abstraction layer, SQL abstraction, result set abstraction, and RowDataGateway and TableDataGateway implementations

v1.0.0(1mo ago)0132BSD-3-ClausePHPPHP ^8.1

Since Apr 24Pushed 1mo agoCompare

[ Source](https://github.com/flyokai/laminas-db)[ Packagist](https://packagist.org/packages/flyokai/laminas-db)[ Docs](https://laminas.dev)[ RSS](/packages/flyokai-laminas-db/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (12)Versions (8)Used By (2)

flyokai/laminas-db
==================

[](#flyokailaminas-db)

> User docs → [`README.md`](README.md) · Agent quick-ref → [`CLAUDE.md`](CLAUDE.md) · Agent deep dive → [`AGENTS.md`](AGENTS.md)

> Database abstraction layer for the Flyokai framework — fork of [`laminas/laminas-db`](https://github.com/laminas/laminas-db).

Provides the synchronous foundation: adapters, drivers, SQL builders, table gateways, and platform-specific dialect generation. Async behaviour is added on top by sibling packages — this fork keeps the upstream API intact.

> Use [`flyokai/laminas-db-driver-amp`](../laminas-db-driver-amp/README.md) (native AMPHP MySQL) or [`flyokai/laminas-db-driver-async`](../laminas-db-driver-async/README.md) (PDO/MySQLi worker pools) on top of this package for non-blocking I/O.

Features
--------

[](#features)

- **Adapters &amp; drivers** — Pdo, Mysqli, Pgsql, Oci8, IbmDb2, Sqlsrv
- **SQL builders** — `Select`, `Insert`, `Update`, `Delete` with fluent, platform-agnostic API
- **Platform abstraction** — Mysql, Postgresql, Oracle, SqlServer, Sqlite, IbmDb2, Sql92
- **Predicate system** — Between, EqualTo, In, IsNull, Like, …
- **TableGateway** — `select()`, `insert()`, `update()`, `delete()` with a feature/plugin system
- **Result sets** — buffered or forward-only
- **Metadata** — schema introspection (`MysqlMetadata`, `PostgresqlMetadata`, …)

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

[](#installation)

```
composer require laminas/laminas-db
```

Composer's `replace` makes this fork resolve under the upstream name automatically inside Flyokai installs.

Quick start
-----------

[](#quick-start)

```
use Laminas\Db\Adapter\Adapter;
use Laminas\Db\Sql\Sql;

$adapter = new Adapter([
    'driver'   => 'Pdo_Mysql',
    'database' => 'app',
    'username' => 'app',
    'password' => 'secret',
    'hostname' => 'localhost',
]);

$sql    = new Sql($adapter);
$select = $sql->select('users')
              ->where(['status' => 'active'])
              ->order('created DESC')
              ->limit(20);

$stmt = $sql->prepareStatementForSqlObject($select);
$rows = iterator_to_array($stmt->execute());
```

Adapter
-------

[](#adapter)

Coordinates driver + platform + query execution.

- Query modes: `QUERY_MODE_PREPARE` (parameterised) / `QUERY_MODE_EXECUTE` (direct)
- `ProfilerInterface` support for query profiling
- Factory methods: `createStatement()`, `createDriver()`, `createPlatform()`

SQL builders
------------

[](#sql-builders)

```
use Laminas\Db\Sql\Sql;

$sql    = new Sql($adapter);

$insert = $sql->insert('users')
    ->columns(['email', 'name'])
    ->values(['a@b.com', 'Alice']);

$update = $sql->update('users')
    ->set(['status' => 'disabled'])
    ->where(['email' => 'a@b.com']);

$delete = $sql->delete('users')->where(['email' => 'a@b.com']);
```

`Sql::buildSqlString($sqlObject)` generates platform-aware SQL; `Sql::prepareStatementForSqlObject($sqlObject)` returns a prepared statement.

TableGateway
------------

[](#tablegateway)

```
use Laminas\Db\TableGateway\TableGateway;

$users = new TableGateway('users', $adapter);

$users->insert(['email' => 'a@b.com', 'name' => 'Alice']);
$rows = $users->select(['status' => 'active']);
$users->update(['status' => 'inactive'], ['id' => 7]);
$users->delete(['id' => 7]);
```

A `FeatureSet` plugs in pre/post operation hooks (e.g. metadata introspection, hydrator-based mapping).

Async integration points
------------------------

[](#async-integration-points)

Async packages extend this foundation by:

1. Implementing `DriverInterface` / `ConnectionInterface` non-blockingly.
2. Wrapping `Statement::execute()` and `Connection::execute()` for fiber suspension.
3. Using the `Feature` system in `TableGateway` for async lifecycle hooks.

See [`flyokai/laminas-db-driver-amp`](../laminas-db-driver-amp/README.md) and [`flyokai/laminas-db-driver-async`](../laminas-db-driver-async/README.md).

Gotchas
-------

[](#gotchas)

- **Empty WHERE protection** — `Update` and `Delete` have `$emptyWhereProtection = true` by default. They refuse to run without a WHERE clause to prevent full-table operations.
- **Forward-only results** — default is streaming. Call `buffer()` on the result set to enable re-iteration.
- **Platform abstraction** — SQL objects don't generate SQL directly; that's delegated to platform classes via `Sql::buildSqlString()`.
- **Parameter naming** — driver-specific (PostgreSQL `$1, $2` vs MySQL `?`). Use `ParameterContainer` for binding.
- **No async in this package** — use the driver-\* siblings.

License
-------

[](#license)

BSD-3-Clause — Copyright (c) Laminas Project. See `LICENSE.md`.

See also
--------

[](#see-also)

- [`flyokai/laminas-db-driver-amp`](../laminas-db-driver-amp/README.md) — async via `amphp/mysql`
- [`flyokai/laminas-db-driver-async`](../laminas-db-driver-async/README.md) — async via worker pools / `MYSQLI_ASYNC`
- [`flyokai/laminas-db-bulk-update`](../laminas-db-bulk-update/README.md) — bulk inserts, ID resolution, range chunking
- [`flyokai/zend-db-sql-insertmultiple`](../zend-db-sql-insertmultiple/README.md) — multi-row `INSERT VALUES`
- Upstream:

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance90

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.8% 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 ~127 days

Total

4

Last Release

50d ago

PHP version history (2 changes)v2.20.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

v2.20.0.1PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![weierophinney](https://avatars.githubusercontent.com/u/25943?v=4)](https://github.com/weierophinney "weierophinney (4941 commits)")[![Maks3w](https://avatars.githubusercontent.com/u/1301698?v=4)](https://github.com/Maks3w "Maks3w (649 commits)")[![Ocramius](https://avatars.githubusercontent.com/u/154256?v=4)](https://github.com/Ocramius "Ocramius (568 commits)")[![ezimuel](https://avatars.githubusercontent.com/u/475967?v=4)](https://github.com/ezimuel "ezimuel (321 commits)")[![michalbundyra](https://avatars.githubusercontent.com/u/7423207?v=4)](https://github.com/michalbundyra "michalbundyra (193 commits)")[![EvanDotPro](https://avatars.githubusercontent.com/u/5607?v=4)](https://github.com/EvanDotPro "EvanDotPro (179 commits)")[![akrabat](https://avatars.githubusercontent.com/u/33135?v=4)](https://github.com/akrabat "akrabat (153 commits)")[![mwillbanks](https://avatars.githubusercontent.com/u/38209?v=4)](https://github.com/mwillbanks "mwillbanks (106 commits)")[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (103 commits)")[![ralphschindler](https://avatars.githubusercontent.com/u/76674?v=4)](https://github.com/ralphschindler "ralphschindler (66 commits)")[![marc-mabe](https://avatars.githubusercontent.com/u/302689?v=4)](https://github.com/marc-mabe "marc-mabe (45 commits)")[![turrsis](https://avatars.githubusercontent.com/u/2911165?v=4)](https://github.com/turrsis "turrsis (43 commits)")[![leftbrained](https://avatars.githubusercontent.com/u/1720071?v=4)](https://github.com/leftbrained "leftbrained (40 commits)")[![romulobusatto](https://avatars.githubusercontent.com/u/2951677?v=4)](https://github.com/romulobusatto "romulobusatto (39 commits)")[![kabel](https://avatars.githubusercontent.com/u/675956?v=4)](https://github.com/kabel "kabel (35 commits)")[![sgehrig](https://avatars.githubusercontent.com/u/43394?v=4)](https://github.com/sgehrig "sgehrig (33 commits)")[![DASPRiD](https://avatars.githubusercontent.com/u/233300?v=4)](https://github.com/DASPRiD "DASPRiD (29 commits)")[![Freeaqingme](https://avatars.githubusercontent.com/u/33034?v=4)](https://github.com/Freeaqingme "Freeaqingme (24 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (22 commits)")[![ghostwriter](https://avatars.githubusercontent.com/u/9754361?v=4)](https://github.com/ghostwriter "ghostwriter (20 commits)")

---

Tags

laminasdb

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laminas/laminas-db

Database abstraction layer, SQL abstraction, result set abstraction, and RowDataGateway and TableDataGateway implementations

14023.5M236](/packages/laminas-laminas-db)[doctrine/doctrine-orm-module

Laminas Module that provides Doctrine ORM functionality

4567.6M299](/packages/doctrine-doctrine-orm-module)[doctrine/doctrine-module

Laminas Module that provides Doctrine basic functionality required for ORM and ODM modules

4048.2M124](/packages/doctrine-doctrine-module)[doctrine/doctrine-mongo-odm-module

Laminas Module which provides Doctrine MongoDB ODM functionality

87689.5k35](/packages/doctrine-doctrine-mongo-odm-module)[doctrine/doctrine-laminas-hydrator

Doctrine hydrators for Laminas applications

383.1M24](/packages/doctrine-doctrine-laminas-hydrator)[sylius/order

Orders management library for PHP.

24483.9k30](/packages/sylius-order)

PHPackages © 2026

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