2013-06-04 52 views
1

我已經構建了自己的mvc框架,並且使用Doctrine DBAL 2.3作爲數據庫層。 目前我正在研究這個框架的剖析器。 我想在探查器中放置的事情之一是在當前頁面上執行的查詢數量。Doctrine dbal count執行的查詢數

我的問題是:我可以從教義中得到查詢的數量嗎? 是嗎?我怎樣才能做到這一點? 不是嗎?有沒有一種方法可以構建一些適用於Doctrine的自定義功能,並完成這個技巧?

我希望有人能回答我的問題,謝謝。

回答

1

學說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

對不起,這麼久來回答,我要感謝你的回答它幫助我很多!謝謝! –

相關問題