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

查看:20
本文介绍了在 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 DoctrineDBALLoggingDebugStack();
$entityManager->getConfiguration()->setSQLLogger($stack);
// do stuff
var_dump($stack);

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

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