在Doctrine2中查询数据库 [英] Count queries to database in Doctrine2

查看:134
本文介绍了在Doctrine2中查询数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Doctrine2中获取对数据库的查询数量?我只需要这个统计数据,并且了解更多的教条如何工作,在不同情况下产生多少查询。但是无论如何,如何做到这一点?

How can i get count of queries to database in Doctrine2? I need this just for statistic and to find out more how doctrine work, how much queries generated in different situations. But anyway, how to do this?

推荐答案

$stack = new \Doctrine\DBAL\Logging\DebugStack();
$entityManager->getConfiguration()->setSQLLogger($stack);
// do stuff
var_dump($stack);

这篇关于在Doctrine2中查询数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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