last query in laravel

pakainfocom profile image pakainfo ・2 min read

In last query in laravel, We have been many time require to get executed query log or you want to get last executed query or maybe if you want to display or Debug sql query from laravel Database query builder then you can do it that. therefore We have four Debugging example for display executed query in Laravel 5/6/7. when you are working on laravel application at that times , We think you require many time to print or debug last run query or if you want to check direct from phpmyadmin sql box, therefore at that time you have to step by step this four Debugging example. therefore, let's follow four Debugging example of debug sql query from MySQL Database Query Builder.

Debugging Example 1 : print or debug last query in laravel eloquent

In this Debugging example we can get directly get current sql query using toSql() of MySQL Database query builder. In this Debugging example you don't require to enable query log or something you can directly query like bellow example:

$employee = Employee::where('id',5)->toSql();

You can visit my Article with More Examples : click here

How to get last query log in Laravel 5/6/7?

If you require to debug your last mysql query in laravel 5/6/7 then you can do it just by bellow multiple Debugging example. We recognize laravel provide their own Database query builder Therefore wherever we write Complex query 3 tables with 2 INNER JOIN, 1 subquery, 2 Group By on mysql Database query builder. But it's give us error, warnning as well as you didn't get it accurately then you require to run manually sql query to your Platform MySQL phpmyadmin.

You can visit my Article with More Examples : click here

Posted on by:

pakainfocom profile



My name is Angular King. I'm a full-stack developer, entrepreneur and owner of Pakainfo. I live in India and I love to write


Editor guide