Repository navigation
Home
Greg Bowler edited this page Mar 3, 2026
·
11 revisions
When we introduce a database layer to an application, we usually want two things: tidy query organisation and predictable access patterns. PHP.Gt/Database gives us both.
In this workshop, we will organise queries into collections, bind data safely, fetch strongly typed values, and run migrations in a repeatable way.
- Query collections using SQL files or PHP query classes
- Named and positional parameter binding
- Type-safe fetching for single values and result sets
- Multiple named database connections
- Migration workflow with integrity checks
- Raw SQL execution for one-off tasks
- Quick start guide
- Configuration and connections
- Query collections
- Parameter binding
- Type-safe getters
- Raw SQL and result sets
- Database migrations
- Examples
$settings = new Gt\Database\Connection\Settings(
__DIR__ . "/query",
Gt\Database\Connection\Settings::DRIVER_SQLITE,
__DIR__ . "/app.sqlite"
);
$db = new Gt\Database\Database($settings);
$row = $db->fetch("user/getById", 42);Now we can move to the Quick start guide and build this out properly.
PHP.GT/Database is a separately maintained component used by PHP.GT/WebEngine.