pyaesoneaung / to-raw-sql
从 Laravel 查询构建器获取原始 SQL
v1.1.3
2023-07-07 08:25 UTC
Requires
- php: ^8.1
- illuminate/contracts: ^9.0|^10.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0|^8.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-09 15:00:52 UTC
README
原始 SQL
⚠️ 默认情况下,toRawSql()
函数包含在 Laravel 10.15.0 中。如果你的 Laravel 版本高于 10.14.1,则不需要安装此包 ⚠️
从 Laravel 查询构建器和 Eloquent 构建器获取原始 SQL
安装
composer require pyaesoneaung/to-raw-sql
使用
User::where('votes', '>', 100) ->orWhere(function ($query) { $query->where('name', 'Abigail') ->where('votes', '>', 50); }) ->toRawSql(); // "select * from `users` where `votes` > 100 or (`name` = 'Abigail' and `votes` > 50)"
DB::table('users') ->whereBetween('votes', [1, 100]) ->toRawSql(); // "select * from `users` where `votes` between 1 and 100"
版本历史
- 1.1.3
- 如果 Laravel 版本高于 10.14.1,则不要注册
toRawSql()
宏
- 如果 Laravel 版本高于 10.14.1,则不要注册
- 1.1.2
- 遇到 PostgreSQL jsonb 操作符错误时抛出 ToRawSqlException
- 1.1.1
- 修复了 pgsql 的布尔绑定
- 1.1.0
- 支持 Illuminate\Database\Query\Builder
- 1.0.2
- 支持 DateTimeInterface 绑定
- 1.0.1
- 修复了字符串绑定
- 1.0.0
- 支持 Illuminate\Database\Eloquent\Builder
测试
composer test