Laravel 6 Print Last Query(Debugging Queries)

Laravel Mysql Mysqli php Programming Technology

Today, We want to share with you Laravel 6 Print Last Query(Debugging Queries).In this post we will show you Laravel 6 Eloquent display query log, hear for Laravel 6 print last executed sql query with Query log we will give you demo and example for implement.In this post, we will learn about query in laravel model Laravel: How to show (or log) all SQL queries executed by Laravel 6 laravel eloquent get last query with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

Laravel 6 Print Last Query(Debugging Queries)

There are the Following The simple About How to get last executed query in Larave 6? Full Information With Example and laravel query builder last insert id source code.

As I will cover this Post with live Working example to develop laravel enable query log with print query in laravel 5.5, so the print last executed query in laravel 6 is used for this example is following below.

Example 1: laravel 6 enable query log

laravel 6 db query log

DB::enableQueryLog();// simple enable query first

    // Your MySQL queries goes here
    // ...

    // And then display/print Queries executed....
    $sql_queries = DB::getQueryLog();
    foreach($sql_queries as $key=>$query)
        Log::debug(" $key Query - " . json_encode($query));

Example 2: laravel 6.0 get last query

get exactly last query using end()

$product = Product::get();
$q_query = DB::getQueryLog();
$q_query = end($q_query);

Example 3: laravel enable query log

using DB::enableQueryLog() of Laravel Query builder. enableQueryLog()

laravel 5 query builder insert last id

$product = Product::get();
$q_query = DB::getQueryLog();

Web Programming Tutorials Example with Demo

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about laravel 5.8, 6.0 & 6.2 query builder with laravel 5 query builder insert get last id.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1.   PHP Rest API Framework List with Features
  2.   CodeIgniter Simple User Registration and Login System
  3.   jQuery Ajax Call to Laravel Script with JSON Return
  4.   PHP Check if Multiple Array contains all Array
  5.   Laravel delete foreign key Constraint Using Migration
  6.   C# .NET Delegates and Events Simplified
  7.   Dynamically Add Remove multiple input fields in PHP MYSQL with Jquery Ajax
  8.   Laravel whereRaw havingRaw and orderByRaw Example
  9.   File upload size validation using Laravel 5.7
  10.   jQuery Ajax POST example with Laravel 7/6

Leave a Reply

Your email address will not be published. Required fields are marked *