-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Muhammet Şafak edited this page May 24, 2026
·
2 revisions
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 eachPDOStatementthat 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();If you are brand new to DBAL:
- Installation — install and pick your driver
- Getting Started — five-minute walkthrough
- Connection — credentials, lifecycle, cloning
If you have a specific question:
- "How do I bind values?" → Querying
- "How do I iterate a large result?" → DataMapper
- "How do I roll back?" → Transactions
- "What exceptions can be thrown?" → Error Handling
- "How do I plug in Monolog?" → Logging
- "How is the package built?" → Architecture
- "I am upgrading from 1.x" → Migration from 1.x
If you are contributing:
- Contributing — process and test expectations
- Testing Your Application — patterns for testing code that depends on DBAL
-
Not a query builder. Use
initorm/query-builder(or any other) on top. -
Not an ORM. Use
initorm/ormor another mapper. - Not a migration tool, schema dumper, or fixture loader.
- Not a connection pool. PHP's lifecycle is per-request; DBAL respects that.
- License: MIT
- PHP: 8.0+
- Stable: 2.0
- Repo: github.com/InitORM/DBAL
- Issues: github.com/InitORM/DBAL/issues
InitORM DBAL · MIT · maintained by Muhammet ŞAFAK · part of the InitORM stack
Getting Started
Core
Cross-Cutting
Reference
Upgrading
Project