mini\vdb()
Function
Documentation
Get a VirtualDatabase session for the current request scope
Returns a Session that wraps the VirtualDatabase. Each request/fiber gets its own Session with isolated temporary tables. Use getEngine() to access the underlying VirtualDatabase for table registration.
Usage:
// Standard querying
vdb()->query("SELECT * FROM countries WHERE continent = ?", ['Europe']);
vdb()->queryOne("SELECT * FROM users WHERE id = ?", [123]);
// Temporary tables (isolated per request/fiber)
vdb()->exec("CREATE TEMPORARY TABLE tmp AS SELECT * FROM users WHERE active = 1");
vdb()->query("SELECT * FROM tmp");
// Access underlying engine for table registration
vdb()->getEngine()->registerTable('data', new ArrayTable(...$columns));
Signature
function vdb(): mini\Database\Session