Doctrine dbal count执行的查询数

问题描述:

我已经构建了自己的mvc框架,并且使用Doctrine DBAL 2.3作为数据库层。 目前我正在研究这个框架的剖析器。 我想在探查器中放置的事情之一是在当前页面上执行的查询数量。Doctrine dbal count执行的查询数

我的问题是:我可以从教义中得到查询的数量吗? 是吗?我怎样才能做到这一点? 不是吗?有没有一种方法可以构建一些适用于Doctrine的自定义功能,并完成这个技巧?

我希望有人能回答我的问题,谢谢。

学说2提供了日志记录一个简单的界面,即\原则\ DBAL \日志\ SQLLogger()

https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Logging/SQLLogger.php

$config = new Doctrine\ORM\Configuration(); 
// ... config stuff 
$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); 
$connectionParams = array(
     'dbname' => 'example', 
     'user' => 'example', 
     'password' => 'example', 
     'host' => 'localhost', 
     'driver' => 'pdo_mysql'); 
//make the connection through an Array of params ($connectionParams) 
$em = EntityManager::create($connectionParams, $config); 
+0

对不起,这么久来回答,我要感谢你的回答它帮助我很多!谢谢! –