-
Notifications
You must be signed in to change notification settings - Fork 0
Recipes
Muhammet Şafak edited this page May 24, 2026
·
1 revision
Self-contained, copy-pasteable solutions to specific problems. Every recipe targets a real use case and includes the surrounding context (schema, controller wiring, test angle when it helps).
If a recipe you need is missing, please open an issue — recipes ship eagerly.
| Recipe | Use case |
|---|---|
| Pagination | Build a simple ?page=&per_page= paginator over a query, with the total page count. |
| Search & Filters | Build a search form whose fields combine into a single safe WHERE clause. |
| Upsert / REPLACE INTO | Insert-or-update across MySQL, PostgreSQL and SQLite — when the builder gets in the way. |
| Audit Log | Capture every write into a parallel _audit table inside a transaction. |
| DataTables Bootstrap | A working DataTables.js page from client HTML to server controller. |
| Repository Pattern | Use the package without the global facade, for testability. |
Each page follows the same skeleton:
- Problem — the question the recipe answers.
- Schema — any SQL you need before the code makes sense.
- Code — the actual implementation, runnable.
- Tests — what to assert against if you want to verify it works.
- Variations — common extensions / what to change for adjacent use cases.
Recipes are pragmatic, not exhaustive. If something interesting comes up in the variations that deserves its own page, it gets one.
initphp/database · MIT License · part of the InitPHP family
Source · Issues · Discussions · Packagist · Contributing · Security Policy
Getting Started
Core API
ORM
Advanced
DataTables Helper
Recipes
- Index
- — Pagination
- — Search & Filters
- — Upsert / REPLACE INTO
- — Audit Log
- — DataTables Bootstrap
- — Repository Pattern
Reference
Migration & Help