thesis / postgres
PostgreSQL build of Thesis based on PDO
dev-master
2021-07-01 04:18 UTC
Requires
- php: ^8.0
- ext-pdo: *
- thesis/thesis: dev-master
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- icanhazstring/composer-unused: ^0.7
- maglnet/composer-require-checker: ^3.3
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ~0.15
- vimeo/psalm: ^4.8
This package is auto-updated.
Last update: 2024-11-10 13:33:21 UTC
README
Basic usage
use Thesis\Postgres\PostgresPdoDriver; use Thesis\Postgres\PostgresDsn; use Thesis\StatementContext\Tsx; $driver = new PostgresPdoDriver(); $connection = $driver->connect( new PostgresDsn( host: 'localhost', port: 5432, user: 'user', password: 'password', databaseName: 'application', ) ); $userId = 'df2d4e8e-d3d7-442b-9415-28aee4d7ab28'; $connection ->execute( static fn (Tsx $tsx): string => <<<SQL select first_name from users where user_id = {$tsx($userId)} SQL ) ->rowColumn('first_name') ->fetch(static fn() => throw new \Exception(sprintf( 'User with id %s was not found.', $userId ))) ;