pyaesoneaung / to-raw-sql
Get raw SQL from Laravel Query Builder
Installs: 7 148
Dependents: 0
Suggesters: 0
Security: 0
Stars: 54
Watchers: 1
Forks: 4
Open Issues: 2
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-11-09 15:20:44 UTC
README
To Raw SQL
⚠️ The toRawSql()
function is included by default in Laravel 10.15.0. You don't need to install this package if your Laravel version is greater than 10.14.1 ⚠️
Get raw SQL from Laravel Query Builder and Eloquent Builder
Installation
composer require pyaesoneaung/to-raw-sql
Usage
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"
Version History
- 1.1.3
- do not register the
toRawSql()
macro if the Laravel version is greater than 10.14.1
- do not register the
- 1.1.2
- throw ToRawSqlException when encountering PostgreSQL jsonb operator errors
- 1.1.1
- fixed boolean bind for pgsql
- 1.1.0
- support Illuminate\Database\Query\Builder
- 1.0.2
- support DateTimeInterface bind
- 1.0.1
- fixed string bind
- 1.0.0
- support Illuminate\Database\Eloquent\Builder
Testing
composer test