如何在 Zend Framework 中分析 Doctrine

发布于 2024-08-25 04:35:53 字数 749 浏览 3 评论 0 原文

再会。

我使用 Doctrine 作为我的 Zend Framework 项目的 ORM。这是我第一次使用它。我已经遵循了 ZendCasts Doctrine 章节,一切都对我有用,但我需要执行一些分析;

有一个 Doctrine_Connection_Profiler 类应该用于分析 Doctrine 模型内部查询,但我尝试使用它但没有成功。当我执行单元测试时,我总是收到“PDOException:您无法序列化或反序列化 PDOStatement 实例”异常。

这是一个示例:

$conn = Doctrine_Manager::connection($doctrineConfig['dsn'], $dbconfname);
...
if( APPLICATION_ENV != 'production'){
    $obj_doctrine_profiler = new Doctrine_Connection_Profiler();
    $conn->setListener($obj_doctrine_profiler);
}

如果我注释/删除该行,我的所有单元测试都会起作用

$conn->setListener($obj_doctrine_profiler);

。该代码块位于我的 Bootstrap.php 类中;奇怪的是,即使使用上述代码行,Web 应用程序也能正常工作。

非常感谢您的帮助。

如果我的英语不是最好的,请原谅。

Good day.

I'm using Doctrine as ORM for my Zend Framework project. This is the first time I use it. I've followed the ZendCasts Doctrine chapters, and everything works for me, but I needed to perform some profiling;

There is a Doctrine_Connection_Profiler class that should be used to profile the Doctrine Model internal queries, but I've tried to use it without success. I always get a "PDOException: You cannot serialize or unserialize PDOStatement instances" exception when I perform my Unit Tests.

Here is a example:

$conn = Doctrine_Manager::connection($doctrineConfig['dsn'], $dbconfname);
...
if( APPLICATION_ENV != 'production'){
    $obj_doctrine_profiler = new Doctrine_Connection_Profiler();
    $conn->setListener($obj_doctrine_profiler);
}

All of my Unit Tests works if I comment/delete the

$conn->setListener($obj_doctrine_profiler);

line. This code block is located in my Bootstrap.php class; the weird thing is, the web application works just fine even with the mentioned code line.

Thank you so much for your help.

please excuse me if my english is not the best.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

離殇 2024-09-01 04:35:53

Zend Framework 的第三方插件和库可以帮助我解决这个问题。该库称为 ZFDebug,并且还有一个 Doctrine 适配器(默认情况下不包含在 ZFDebug 库中)。完整的说明位于 ZFDebug 包内。 Doctrine 插件显示所有事件、查询和在数据库内容中花费的测量时间。

There is a third party Plugin and Library for Zend Framework that helped me with this issue. The library is called ZFDebug and there is too a Doctrine adapter (wich doesn't come in the ZFDebug library by default). Full instructions are inside the ZFDebug package. The Doctrine plugin displays all the events, the queries and the measured time spent in Database stuffs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文