laravel查询日志缺少更新查询

r7knjye2  于 2021-06-20  发布在  Mysql
关注(0)|答案(2)|浏览(255)

我在控制器中有这个代码(laravel 5.6):

\DB::enableQueryLog();
$foo->update($data);
dd(\DB::getQueryLog());

问题是垃圾堆里没有 update 查询。我知道 update 命令正在运行(我可以在数据库中看到更新的数据)。我错过了什么?

idfiyjo8

idfiyjo81#

尝试查询生成器:

DB::connection()->enableQueryLog();
DB::connection('your-connection')->update($data);
$queries = DB::getQueryLog();
dd($queries);

如果不成功的话,你可能想看看这个。

jutyujz0

jutyujz02#

你可能会有更好的运气:

\DB::connection()->enableQueryLog();
$foo->update($data);
dd(\DB::getQueryLog());

个人选择,但我甚至会修改它一点:

\DB::connection()->enableQueryLog();
$foo->update($data);
print_r(\DB::getQueryLog());
die();

您可能更喜欢输出。

相关问题