Skip to content
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.

What we will cover

  • 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

Where to go next

Quick reminder

$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.

Clone this wiki locally