itrn0/php-sql-interpolator
最新稳定版本:v1.1.0
Composer 安装命令:
composer require itrn0/php-sql-interpolator
包简介
A library for interpolating variables into SQL strings in a safe and simple way.
README 文档
README
PHP SQL Interpolator is a library that allows you to safely interpolate variables into SQL queries. The library is designed to prevent SQL injection.
Installation
You can install the library via composer:
composer require itrn0/php-sql-interpolator
Usage
To use the library, you need to create a new instance of the SqlInterpolator class and use the __invoke method to interpolate variables into your SQL query.
$interp = new SqlInterpolator(); $userId = 1002; $query = <<<SQL SELECT * FROM users WHERE id = {$interp($userId)} OR name IN ({$interp('Alice', 'Bob')}) SQL; $params = $interp->getParams(); // { ":param_1" => 1002, ... } // database query example $db->query($query, $params);
统计信息
- 总下载量: 166
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-23