-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Muhammet Şafak edited this page May 24, 2026
·
2 revisions
initorm/database is the glue layer of the InitORM stack.
It composes the connection layer (initorm/dbal)
and the fluent query builder (initorm/query-builder)
into a single, fluent Database manager with:
-
CRUD helpers —
create,createBatch,read,update,updateBatch,delete -
Transactions with retry +
testMode - Query log profiler for finding N+1 problems and slow queries
-
Optional static facade (
DB::…) for application code that doesn't need DI
use InitORM\Database\Facade\DB;
DB::createImmutable([
'dsn' => 'mysql:host=localhost;dbname=app;charset=utf8mb4',
'username' => 'app',
'password' => 'secret',
]);
$users = DB::select('id', 'name')
->where('active', '=', 1)
->orderBy('id', 'DESC')
->limit(10)
->read('users')
->asAssoc()
->rows();If you are brand new:
- Installation — install and pick your driver
- Getting Started — first ten minutes
- Configuration — every credential, explained
If you have a specific question:
| Question | Page |
|---|---|
| "How do I run an INSERT/UPDATE/DELETE?" | CRUD Operations |
| "How do I build a SELECT with joins?" | Query Builder |
| "How do I execute raw SQL?" | Raw Queries |
| "How do I commit/rollback?" | Transactions |
| "How do I use the static facade safely?" | Static Facade |
| "Can I use multiple databases?" | Multiple Connections |
| "How do I log slow queries?" | Query Profiler |
| "How do I route failures to Monolog?" | Logging and Debug |
"How does the __call magic work?" |
Architecture |
| "How do I paginate / chunk / bulk insert?" | Recipes |
| "Is X possible? Why does Y throw?" | FAQ |
If you are upgrading:
- Migration from v2 to v3 — every breaking change with a diff.
If you are contributing:
- Contributing — testing patterns, PR process, quality bar.
-
Not an ORM. Models, hooks, accessors/mutators live in
initorm/orm. - Not a migration tool, schema dumper, or fixture loader.
-
Not a connection pool. PHP's request lifecycle handles that; persistent connections live in
options[PDO::ATTR_PERSISTENT]. -
Not a query builder by itself. That's
initorm/query-builder; this package exposes its full surface through__call.
┌────────────────────────────────────────────────────────┐
│ initorm/orm ← active-record models, hooks │
├────────────────────────────────────────────────────────┤
│ initorm/database ← ★ you are here │
│ CRUD + transactions + facade │
├────────────────────┬───────────────────────────────────┤
│ initorm/dbal │ initorm/query-builder │
│ Connection (PDO) │ QueryBuilder (SQL assembly) │
│ DataMapper │ Compilers (string-join) │
└────────────────────┴───────────────────────────────────┘
Pick any layer — they don't force you to use the one above.
- License: MIT
- PHP: 8.1+
- Stable: 3.0
- Repo: github.com/InitORM/Database
- Packagist: packagist.org/packages/initorm/database
- Issues: github.com/InitORM/Database/issues
InitORM Database · MIT · maintained by Muhammet ŞAFAK · part of the InitORM stack
Getting Started
Core Operations
Cross-Cutting
Reference
Upgrading
Project