Skip to content
Muhammet Şafak edited this page May 24, 2026 · 2 revisions

InitORM DBAL — Wiki

A small, dependency-free Database Abstraction Layer for PHP, built on top of PDO. DBAL gives you two things and nothing more:

  • Connection — a lazily-connecting PDO wrapper with credential management, driver-aware DSN building, query logging, and pluggable failure logging.
  • DataMapper — a fluent wrapper around each PDOStatement that takes care of value binding and fetch-mode selection.

DBAL is the second layer of the InitORM stack, but it has no runtime dependencies — you can drop it into any PHP 8.0+ project without buying into the rest of the stack.

use InitORM\DBAL\Connection\Connection;

$db = new Connection([
    'driver'   => 'mysql',
    'host'     => '127.0.0.1',
    'database' => 'shop',
    'username' => 'app',
    'password' => 'secret',
]);

$user = $db->query('SELECT id, name FROM users WHERE id = :id', ['id' => 7])
           ->asAssoc()
           ->row();

How to read this wiki

If you are brand new to DBAL:

  1. Installation — install and pick your driver
  2. Getting Started — five-minute walkthrough
  3. Connection — credentials, lifecycle, cloning

If you have a specific question:

If you are contributing:

What DBAL is not

  • Not a query builder. Use initorm/query-builder (or any other) on top.
  • Not an ORM. Use initorm/orm or another mapper.
  • Not a migration tool, schema dumper, or fixture loader.
  • Not a connection pool. PHP's lifecycle is per-request; DBAL respects that.

Package status

Clone this wiki locally