Ways to print SQL query in laravel
Category:
Laravel
Tags:
Laravel
Sreerag Nair
6 months ago
1. Print the SQL query, stop the execution(dump and die) and show the parameters along with the query.
User::where('id',Auth::guard('user')->user()->id)->ddRawSQL();
2. Print the SQL query, stop the execution(dump and die), but doesn't show the parameters along with the query.
User::where('id',Auth::guard('user')->user()->id)->dd();
3. Print the SQL query but doesn't do dump and die and doesn't show the parameters.
User::where('id',Auth::guard('user')->user()->id)->toSQL()
4. Print the SQL query but doesn't do dump and die but shows the parameters along with the query.
User::where('id',Auth::guard('user')->user()->id)->toRawSQL()