PHP + MySQL探查器

bea*_*ear 4 mysql profiling

你知道vBulletin在调试模式下有一个sql profiler吗?我如何为自己的Web应用程序构建一个?它是用程序PHP构建的.

谢谢.

Mik*_*tar 7

http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.html

以上链接链接了如何在任何查询后获取sql配置文件信息.

实现它的最佳方法是创建一个数据库类,并使其具有"profile"标志,以打开查询记录和相应的信息,如上面链接所示.

例:

Class dbthing{
  var $profile = false;

  function __construct($profile = false){
    if($profile){
      $this->query('set profiling=1');
      $this->profile = true;
    }
    ...
  }

  function query($sql, $profile_this == false){
     ...
     if($this->profile && !$profile_this)
        $this->query("select sum(duration) as qtime from information_schema.profiling where query_id=1", true);
     ... // store the timing here
  }

}
Run Code Online (Sandbox Code Playgroud)