Database
Source-reviewed against the pinned revision below. This is a component integration guide, not a claim of a complete tested application matrix.
Package and installation
Section titled “Package and installation”triangle/database · AGPL-3.0-or-later
composer require triangle/databasecomposer check-platform-reqscomposer show triangle/databaseThe command resolves the available release, not necessarily the source revision reviewed here. Keep and validate your application lock. Direct requirements do not describe all transitive PHP/extension constraints.
| Requirement | Constraint |
|---|---|
php | ^8.1 |
triangle/engine | ^8.1 |
illuminate/database | ~11.19.0 |
illuminate/pagination | ~11.19.0 |
illuminate/events | ~11.19.0 |
symfony/var-dumper | ~7.1.0 |
Architecture
Section titled “Architecture”The query facade is Triangle\Database\Manager, extending Illuminate Capsule; the model base is Triangle\Database\Model. The component bootstraps Eloquent, named connections and pagination resolvers. It does not provide Triangle\Database\DB or Triangle\Database\Facades\Db.
Configuration and lifecycle
Section titled “Configuration and lifecycle”config/database.php supplies default, persistent and connections. Bootstrap returns without connections or Capsule. It registers the default/named connections, sets Capsule global and boots Eloquent. With a Server and persistent mode it schedules a 55-second heartbeat for existing MySQL connections; a heartbeat is not a connection pool or an automatic safe retry of transactions.
Parameterized queries
Section titled “Parameterized queries”use Triangle\Database\Manager as DB;
$rows = DB::select('select id from users where email = ?', [$email]);Run after database bootstrap, with a migrated users table and a validated email. Query bindings protect values, not dynamic table/column identifiers. Whitelist any identifiers chosen by users.
Transactions and persistent workers
Section titled “Transactions and persistent workers”The inherited Capsule API includes connection/query/transaction operations. Scope transactions to a unit of work, propagate failures, roll back before reusing a connection and avoid external side effects inside a retryable transaction. Eloquent and PDO calls remain blocking unless a separate driver/runtime explicitly provides async behavior. Configure the matching PDO extension; MongoDB support additionally needs the chosen compatible driver. Test disconnect/reconnect and transaction isolation against the exact lock.
Source and verification
Section titled “Source and verification”Database · 90d6f6cbc467. Framework startup limits.