Home > Backend Development > PHP Tutorial > laravel 5.1 如何打印最后一次执行的sql

laravel 5.1 如何打印最后一次执行的sql

WBOY
Release: 2016-06-06 20:16:51
Original
1546 people have browsed it

如何取出最后一次执行的sql

回复内容:

如何取出最后一次执行的sql

<code>DB::connection()->enableQueryLog(); // 开启查询日志

DB::table('xxx'); // 要查看的sql

$queries = DB::getQueryLog(); // 获取查询日志

print_r($queries); // 即可查看执行的sql,传入的参数等等</code>
Copy after login

Laravel 5.0 是這樣取出的,5.1應該也通用

<code>$queries = DB::getQueryLog();</code>
Copy after login

你也可以裝下這個Laravel-debugbar組件,我平時sql語句調試都是用它

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