Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
sfWebDebugPanelPropel に Explain の結果を追加表示
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README
akWebDebugPanelPropel.class.php

README

akWebDebugPanelPropel
==============

sfWebDebugPanelPropel に以下の表示を追加します。

 * Explain結果の表示・警告
 * 指定回数以上のクエリが発行された場合の警告


Example
=======

frontendConfiguration.class.php

<?php

class frontendConfiguration extends sfApplicationConfiguration
{
    public function configure()
    {
    }

    public function initialize()
    {
        if (sfConfig::get('sf_web_debug')) {
            $this->dispatcher->connect('debug.web.load_panels', array($this, 'webLoadPanelEvent'));
        }
    }

    public function webLoadPanelEvent($event)
    {
        $debug = $event->getSubject();
        $panel = new akWebDebugPanelPropel($debug);

        // デフォルトのexplain警告条件を差し替え
        // $panel->setIsWarningCallable(array($this, 'isWarningExplain'));

        $debug->setPanel('db', $panel);
    }

    public function isWarningExplain($explain)
    {
        foreach ($explain as $v) {
            if ($v['type'] == 'ALL' || preg_match('!filesort|temporary!', $v['Extra'])) {
                return true;
            }
        }

        return false;
    }
}


databases.yml

dev:
  propel:
    param:
      classname:  DebugPDO
      debug:
        realmemoryusage: true
        dsn: true
        query_count:  20
        explain:
          type:  '/index|ALL/'
          Extra: '/filesort|temporary/'
        details:
          time:       { enabled: true }
          slow:       { enabled: true, threshold: 0.1 }
          mem:        { enabled: true }
          mempeak:    { enabled: true }
          memdelta:   { enabled: true }
Something went wrong with that request. Please try again.