当前位置: 动力学知识库 > 问答 > 编程问答 >

debugging - Is there a way to show in the query log on which file or class the query was executed on?

问题描述:

I currently have a reasonably big application running on cakephp, some pages generate quite a few queries to the database. Some queries are called in current controller, but others maybe called on a function on a remote model, also while using containable behavior with many models related it's becoming quite difficult to know from where certain query came from to optimize it.

I search on the docs but there's nothing about configuring the query log, also installed the debugkit but haven't found any functionality capable of doing that.

Any hints?

网友答案:

Encapsulate your sql connection in a PHP class, and make your query method log extra information. Another method is to add comments to the SQL query itself "--" characters denote a comment, and manually add the current PHP file path.

分享给朋友:
您可能感兴趣的文章:
随机阅读: