kenny1911/doctrine-sqlx 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. More readable code - parameters are visible directly in SQL strings
  2. Easier refactoring - no need to synchronize parameter names
  3. Security - all parameters are properly escaped
  4. Type support - explicit parameter type specification

Limitations

  1. Requires PHP 8.1+
  2. Works only with Doctrine DBAL 3.x and 4.x

Related Projects

License

MIT

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-24