如何在 MVC 框架中分析 SQL 查询?
我一直在开发自己的 php MVC 框架。我只是想了解您关于如何分析在我的框架上运行的所有查询的想法。我已经完成了其他分析工作,但我不清楚如何分析 sql 查询,以便用户查看他们是否打开分析。
谢谢
I have been working on my own php MVC framework. I just wanted to get your ideas on how to profile all the queries run on my framework. I have done other profiling stuff but i have no clear idea of how to profile the sql queries too for the users to see if they turn profiling on.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这实际上取决于您想要多少信息,但为了对您来说有点通用,我会考虑这样的东西(该类是您用来与数据库交互的任何内容):
这显然是一个非常简单的示例,但是这样既非常简单,而且在可以存储的东西方面也非常强大。例如,您还可以存储受查询影响的行数、查询涉及的表数等。
It really depends on how much information you want, but to be a bit generic for you I would consider something this this (the class is whatever you are using to interact with the database):
This is obviously a very simple example, but this way would be both very easy, as well has pretty powerful in terms of things you can store. For example you could also store the number of rows affected by a query, the number of tables a query touches, etc.
Zend Framework 是一个很好的例子。您可以在网站下看到 SQL 查询。如果您编写自己的框架,您可以遵循这种方式。用户可以打开或关闭一个布尔变量。如果他们将其设置为“true”,您可以在网页下编写sql查询。通过该解决方案,编码人员可以查看 MySQL 正在运行哪些查询。
Zend Framework is a good example for you. You can see SQL queries under the web site. If you write your own framework you can follow that way. Users can open or close one boolean variable. If They set it "true" you can write sql queries under the web page. With that solution coders can see which queries are running by MySQL.
Nusphere PhpED v10 附带 PHP SQL 分析器,适用于所有 PHP 框架和根本没有任何框架的项目。
http://www.nusphere.com/products/php_sql_profiler.htm
Nusphere PhpED v10 comes with PHP SQL profiler that works great with all php frameworks and projects without any frameworks at all.
http://www.nusphere.com/products/php_sql_profiler.htm