kenny1911/doctrine-sqlx
最新稳定版本:0.1.0
Composer 安装命令:
composer require kenny1911/doctrine-sqlx
包简介
README 文档
README
[ English | Русский ]
A library that provides a convenient syntax for working with parameters in Doctrine DBAL SQL queries, allowing direct parameter embedding in SQL strings.
Installation
composer require kenny1911/doctrine-dbal-sqlx
Usage
Basic Example
use Doctrine\DBAL\Connection; use Kenny1911\DoctrineSqlx\Sqlx; use Kenny1911\DoctrineSqlx\Ctx; /** @var Connection $connection */ $sqlx = new Sqlx($connection); $result = $connection->executeQuery(static fn(Ctx $ctx): string => <<<SQL "SELECT * FROM users WHERE id = {$ctx(1)}" SQL); );
Instead of the traditional approach:
$result = $connection->executeQuery( sql: 'SELECT * FROM users WHERE id = :id', params: ['id' => 1], );
Benefits
- More readable code - parameters are visible directly in SQL strings
- Easier refactoring - no need to synchronize parameter names
- Security - all parameters are properly escaped
- Type support - explicit parameter type specification
Limitations
- Requires PHP 8.1+
- Works only with Doctrine DBAL 3.x and 4.x
Related Projects
License
统计信息
- 总下载量: 33
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-24