Laravel 4 SQL 日志/控制台 [英] Laravel 4 SQL log / console

查看:20
本文介绍了Laravel 4 SQL 日志/控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Laravel 中是否有类似的东西可以让你看到正在执行的实际 SQL?例如,在 Rails 中,您可以在控制台中看到 SQL.在 Django 中,您有一个工具栏.

Is there something similar in Laravel that allows you to see the actual SQL being executed? In Rails, for example, you can see the SQL in console. In Django you have a toolbar.

在 Laravel 4 中有类似的东西吗?

Is there something like that in Laravel 4?

澄清一下:我的问题是如何在没有代码的情况下做到这一点.Laravel 中是否有内置的东西不需要我在应用程序中编写代码?

To clarify: My question is how to do it without code. Is there something that is built-in in Laravel that does not require me to write code in app?

更新:最好我也希望看到 CLI 查询(例如 php artisan migrate)

UPDATE: Preferably I'd like to see CLI queries as well (for example php artisan migrate)

推荐答案

如果你使用的是 Laravel 4,使用这个:

If you are using Laravel 4, use this:

$queries    = DB::getQueryLog();
$last_query = end($queries);

这篇关于Laravel 4 SQL 日志/控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆