Home >Backend Development >PHP Tutorial >[Mr. Mai] Laravel SQL statement recording method, laravelsql_PHP tutorial

[Mr. Mai] Laravel SQL statement recording method, laravelsql_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-12 08:51:371013browse

[Mr. Mai] Laravel SQL statement recording method, laravelsql

Print the sql statement and output 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: Pay attention to put it above routes.php

Event::listen('illuminate.query',function($query){

var_dump($query);

});

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1129312.htmlTechArticle[Mr. Mai] Laravel SQL statement recording method, laravelsql prints sql statement, and outputs the method directly after you execute the SQL statement 1: $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