在 zend 框架 db profiler 中看不到描述查询
我在我的开发站点中设置并打开了 zend 数据库分析器。我可以看到除 DESCRIBE 查询之外的所有查询,我知道每次我请求新的表对象时它都应该运行。我正在使用类似的东西来查看查询:
$db = Zend_Registry::get('db');
$profiler = new Zend_Db_Profiler();
$profiler->setEnabled(true);
$db->setProfiler($profiler);
$i = 1;
$output = 'PROFILE FOR: '.$_SERVER['REQUEST_URI'] . "\n";
foreach ($profiler->getQueryProfiles() as $query) {
$output .= "Query ".$i++.": ".$query->getQuery(). "\n";
}
$output .= 'Average query length: ' . $totalTime / $queryCount .
' seconds' . "\n";
$output .= 'Queries per second: ' . $queryCount / $totalTime . "\n";
$output .= 'Longest query length: ' . $longestTime . "\n";
$output .= "Longest query: \n" . $longestQuery . "\n\n";
file_put_contents('/tmp/zend_profiler.log', $output, FILE_APPEND);
}
不知道为什么我看不到描述查询。还有其他人遇到过这个问题吗?
I have zend database profiler set up and turned on in my development site. I can see all the queries except for the DESCRIBE queries, which I know it should be running each time I ask for a new table object. I'm using something like this to look at the queries:
$db = Zend_Registry::get('db');
$profiler = new Zend_Db_Profiler();
$profiler->setEnabled(true);
$db->setProfiler($profiler);
$i = 1;
$output = 'PROFILE FOR: '.$_SERVER['REQUEST_URI'] . "\n";
foreach ($profiler->getQueryProfiles() as $query) {
$output .= "Query ".$i++.": ".$query->getQuery(). "\n";
}
$output .= 'Average query length: ' . $totalTime / $queryCount .
' seconds' . "\n";
$output .= 'Queries per second: ' . $queryCount / $totalTime . "\n";
$output .= 'Longest query length: ' . $longestTime . "\n";
$output .= "Longest query: \n" . $longestQuery . "\n\n";
file_put_contents('/tmp/zend_profiler.log', $output, FILE_APPEND);
}
Not sure why I can't see the describe queries. Has anyone else run into this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您已经为数据库连接激活了元数据缓存(这通常是一件非常好的事情,尤其是在生产中)。在这种情况下,在缓存过期之前,
DESCRIBE
查询不会被执行。通过在引导程序后在应用程序中的某个位置执行此行来验证它
Maybe you have activated the metadata cache for you database connection (which usually is a very good thing especially in production). In that case the
DESCRIBE
queries won't be executed until the cache expires.Verify it by executing this line somewhere in application after the bootstrap