pyaesoneaung/to-raw-sql
Get raw SQL from Laravel Query Builder
11,555
56
| Install | |
|---|---|
composer require pyaesoneaung/to-raw-sql |
|
| Latest Version: | v1.1.3 |
| PHP: | ^8.1 |
| Laravel: | 9 · 10 |
| License: | MIT |
| Last Updated: | Oct 9, 2023 |
| Links: | GitHub · Packagist |
Maintainer: pyaesoneaung

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
Related Packages
doctrine/dbal
Powerful PHP database abstraction layer (DBAL) with many features for database s...
648,266,899
9,701
laravel/serializable-closure
Laravel Serializable Closure provides an easy and secure way to serialize closur...
429,221,767
607
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.1.3 | ^8.1 | ^9.0| | MIT | |
| v1.1.2 | ^8.1 | ^9.0| | MIT | |
| v1.1.1 | ^8.1 | ^9.0| | MIT | |
| v1.1.0 | ^8.1 | ^9.0| | MIT | |
| v1.0.2 | ^8.1 | ^9.0| | MIT | |
| v1.0.1 | ^8.1 | ^9.0| | MIT | |
| v1.0.0 | ^8.1 | ^9.0| | MIT |