This article brings you a Laravel SQL statement recording method (recommended). Share it with everyone and give it as a reference. I hope to be helpful.
Print sql statement, output directly after you execute the SQL statement
Method 1:
$queries = DB::getQueryLog();
$a = end($queries);
$tmp = str_replace('?', '"'.'% s'.'"', $a["query"]);
echo vsprintf($tmp, $a['bindings']);
exit;
Method 2: Pay attention to placing it above routes.php
Event::listen('illuminate.query',function($query){ var_dump($query); });
The above method of recording Laravel SQL statements (recommended) This is all the content that the editor has shared with you. I hope it can give you a reference, and I hope you will support Script House more.
Related recommendations:
Laravel Redis Multiple processes take the queue problem at the same time
An elegant way to generate Gravatar avatar address using Laravel
The reason why Laravel repeatedly executes the same queue task
The above is the detailed content of How Laravel records SQL statements. For more information, please follow other related articles on the PHP Chinese website!