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

Laravel SQL statement recording method (recommended), laravelsql_PHP tutorial

WBOY
Release: 2016-07-12 08:50:51
Original
895 people have browsed it

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);

});
Copy after login

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_...
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