正式 / 访问层
4.0.0
2024-07-14 13:00 UTC
Requires
- php: ~8.2
- innmind/immutable: ~4.0|~5.0
- innmind/specification: ~4.1
- innmind/url: ~4.0
- psr/log: ~3.0
Requires (Dev)
- innmind/black-box: ^5.6.1
- innmind/coding-standard: ~2.0
- vimeo/psalm: ~5.13
Suggests
- innmind/black-box: For property based testing
Provides
Conflicts
- innmind/black-box: <5.0|~6.0
README
这是一个在内置 \PDO
类之上提供极简 API 的简单抽象层。
目标是使用不可变结构和尽可能消除状态来分离查询的表达式和执行。
重要
您必须使用 vimeo/psalm
来确保正确使用此库。
安装
composer require formal/access-layer
示例
use Formal\AccessLayer\{ Connection\Lazy, Connection\PDO, Query\SQL, Row, }; use Innmind\Url\Url; use Innmind\Immutable\Sequence; $connection = Lazy::of(static fn() => PDO::of(Url::of('mysql://user:pwd@127.0.0.1:3306/database_name'))); $rows = $connection(SQL::of('SELECT * FROM `some_table`')); $rows; // instanceof Sequence<Row>
文档
完整的文档可以在 http://formal-php.github.io/access-layer/ 找到。