Home >Backend Development >PHP Tutorial >Laravel SQL statement recording method (recommended), laravelsql_PHP tutorial

Laravel SQL statement recording method (recommended), laravelsql_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:50:51900browse

Laravel SQL statement recording method (recommended), laravelsql

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1133071.htmlTechArticleLaravel SQL statement recording method (recommended), laravelsql prints the sql statement, and outputs the method directly after you execute the SQL statement. : $queries = DB::getQueryLog(); $a = end($queries); $tmp = str_...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn