mini\Database\Session class

Documentation

Database session with isolated temporary tables

A Session wraps a VirtualDatabase engine and provides:

  • Isolated temporary table storage (CREATE TEMPORARY TABLE)
  • Session-scoped state (future: prepared statement cache, transaction state)

In fiber/coroutine environments, each fiber should have its own Session to prevent temp table collisions. The mini\vdb() helper automatically manages session-per-fiber via Lifetime::Scoped.

// Get session (automatically scoped per fiber)
$db = mini\vdb();
$db->exec("CREATE TEMPORARY TABLE tmp (id INTEGER, val TEXT)");
$db->exec("INSERT INTO tmp VALUES (1, 'test')");
$result = $db->query("SELECT * FROM tmp");
// Temp table is automatically cleaned up when fiber ends

Inheritance

Implements: mini\Database\DatabaseInterface

Properties (3)

private array $tempTables
private ?string $lastInsertId
private readonly mini\Database\VirtualDatabase $engine

Methods (24)

Documentation missing

Get the underlying VirtualDatabase engine

Get a temporary table by name

Register a temporary table

Drop a temporary table

Check if a temporary table exists

Get all temporary table names

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Source

src/Database/Session.php:28-220