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

WBOY
Release: 2016-07-12 08:51:37
Original
1001 people have browsed it

[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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template