How to get last executed mysql query in Laravel?

By Hardik Savani | January 12, 2016 | Category : Laravel MySql

If you are working on laravel framwork and you use query builder of laravel 5. but you want to get last executed mysql query from laravel. If you are working on laravel 5 then you have to first enable query log that way it can be store query log. At last getQueryLog() through you can get last executed query.

I give you example of how to get last executed mysql query. you can use example as following example.

public function querylog()



$item = Item::find(2);

$last_query = DB::getQueryLog();



Try this.............

Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.