1

I have build my own mvc framework and i'm using Doctrine DBAL 2.3 as database layer. At the moment i'm working on a profiler for this framework. One of the things i want to put in the profiler is the number of querys that were executed on the current page.

My question is: can i get the number of querys from Doctrine? Yes? How can i do this? No? Is there a way to build something custom that works with Doctrine and does the trick?

I hope there is someone that can answer my question, thank you.

4

1 回答 1

1

Doctrine 2 提供了一个简单的日志接口,即 \Doctrine\DBAL\Logging\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);
于 2013-06-04T19:09:13.053 回答