Search by

kinetis / query-builder

aln-1

A thin, parameterized SQL query builder over kinetis/persistence's MySQL and Postgres drivers, with portable row-to-DTO mapping and pagination envelopes. Usable standalone. Not an ORM: no relationships, no migrations, no change-tracking.

Package info

github.com/kinetis-dev/query-builder

pkg:composer/kinetis/query-builder

Statistics

Installs: 99

Dependents: 3

Suggesters: 1

Stars: 0

Open Issues: 0

v1.7.0 2026-09-21 14:23 UTC

This package is auto-updated.

Last update: 2026-09-21 14:42:02 UTC


README

Kinetis

kinetis/query-builder
A thin, parameterized SQL query builder for MySQL and PostgreSQL

Packagist Version Packagist Downloads PHP Version License CI

Part of Kinetis, a non-blocking PHP framework for API-first applications, developed in the kinetis-dev/kinetis monorepo. Usable standalone: in production it depends only on kinetis/persistence.

Parameterized selects, joins, subqueries, set operations, CTEs, row locks, inserts, upserts, updates and deletes over the SQL shared by MySQL 8.4, MariaDB 11.4 and PostgreSQL 16, run through kinetis/persistence's drivers, with its own row-to-DTO mapping and pagination envelopes. Not an ORM: no relationships, no change-tracking, no save()-on-a-model.

use Kinetis\Persistence\ConnectionDefinition;
use Kinetis\Persistence\SqlConnectionFactory;
use Kinetis\QueryBuilder\Query;

// Build the client once and reuse it across units of work.
$db = SqlConnectionFactory::create(new ConnectionDefinition(
    dialect: 'mysql',
    host: 'db.internal',
    database: 'shop',
    user: 'shop',
    password: $password,
));

$orders = new Query($db)
    ->table('orders')
    ->where('customer_id', '=', $customerId)
    ->where('status', '!=', 'cancelled')
    ->orderBy('created_at', 'desc')
    ->limit(20)
    ->get(OrderRow::class); // OrderRow is your own row DTO

The connection's type selects the SQL dialect, and a Query built on a transaction runs inside it. What the host owns — client lifetime and a TransactionGuard per unit of work — is described in kinetis/persistence.

With Kinetis

composer require kinetis/query-builder kinetis/database-bridge

Install both: kinetis/database-bridge binds the connection from DB_* configuration but does not install the query builder. An application then injects MysqlLink or PostgresLink and constructs new Query($link) per statement with no wiring of its own.

Installation

composer require kinetis/query-builder

Requires PHP 8.4+ and kinetis/persistence, plus the PHP extension for the driver you use. Full documentation: kinetis.dev/docs/query-builder.html.

License

MIT — see LICENSE.