laravel 取sql语句
2024-08-31 13:59:41
\DB::connection()->enableQueryLog(); some sql action... $query = \DB::getQueryLog();
$lastQuery = end($query); dd($lastQuery);
php artisan tinker DB::listen(function($sql){ var_dump($sql); });
Inside AppServiceProvider.php
add the following to the boot method:
use DB;
use Event; //.. public function boot()
{
if (env('APP_ENV') === 'local') {
DB::connection()->enableQueryLog();
}
if (env('APP_ENV') === 'local') {
Event::listen('kernel.handled', function ($request, $response) {
if ( $request->has('sql-debug') ) {
$queries = DB::getQueryLog();
dd($queries);
}
});
}
}
最新文章
- gRPC源码分析0-导读
- Java设计模式(二) 工厂方法模式
- QT学习笔记4
- CMake Error: your CXX compiler: "" was not found
- eval解析非标准json
- sqlmap参数大全
- BZOJ 2173 整数的lqp拆分
- 可配置多功能门 SN74LVC1G57, 1G58, 1G97, 1G98, 1G99
- 用JDBC查询数据库
- jsonString转NSDictionary
- [POJ] 1511 Invitation Cards
- 浙大玉泉ubuntu L2TP VPN连接设置
- 转载自 BotVS 「 珍藏版 」如何搭建一个完整的交易框架
- boostrap中模态框显示在阴影之下
- xml方式将dataset导出excel
- css3 的新属性
- hdu 1385 Floyd 输出路径
- ueditor百度编辑器的赋值方法
- 热烈祝贺阿尔法Go首战告捷
- 【洛谷5280】[ZJOI2019] 线段树(线段树大力分类讨论)
热门文章
- 获取MSSQL Server中的相关信息(视图、存储过程、触发器、表)
- 【HTML5】input类型
- 使用github上的开源框架SlidingMenu环境的搭建,以及getSupportActionBar方法不能找到的问题
- javascript优化--03高质量编码
- Xamarin Anroid开发教程之Anroid开发工具及应用介绍
- 结合ItemsControl在Canvas中动态添加控件的最MVVM的方式
- http://www.cnblogs.com/Matrix54/archive/2012/05/03/2481260.html
- Hadoop科普文——常见的45个问题解答(CSDN)
- iphone6来了,我该做点什么(兼容iphone6的方法)
- HTML head 头标签