donglu1913 2013-06-04 19:00
浏览 56
已采纳

doctrine dbal count执行的查询次数

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.

  • 写回答

1条回答 默认 最新

  • dp709369831 2013-06-04 19:09
    关注

    Doctrine 2 provides a simple interface for logging, namely \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);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊