Home >Backend Development >PHP Tutorial >Laravel SQL statement recording method (recommended), laravelsql_PHP tutorial
prints the sql statement and outputs it 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: Note: Place it above routes.php
Event::listen('illuminate.query',function($query){ var_dump($query); });
The above Laravel SQL statement recording method (recommended) is all the content shared by the editor. I hope it can give you a reference, and I also hope that everyone will support Bangkejia.