Plugin Directory

Changeset 188343


Ignore:
Timestamp:
12/31/2009 01:40:05 AM (16 years ago)
Author:
silasco
Message:

changed query log method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-pear-debug/trunk/wp-pear-debug.php

    r150292 r188343  
    143143        if($sDebug)
    144144        {
     145            //Instruct wordpress to save queries
     146            //Please do this in wp-config.php instead
     147            define('SAVEQUERIES',true);
    145148            //register javascript
    146149            wp_register_script(self::WPD_JS, "".self::url()."/js/html_div.js");
     
    182185    public static function show()
    183186    {
    184         //Get current instance of debug class
    185         $oDebug = self::get();
    186         //Display debug information
    187         $oDebug->display();
    188     }
    189    
     187        //Add query info before render
     188        //This new method should gather most if not all the query info
     189        self::_processQueries();
     190        //Render debug information
     191        self::get()->display();
     192       
     193    }
     194   
     195    //No longer used internally to add query information
     196    //Still available as utility
    190197    //add database query to debug
    191198    public static function query($query)
    192199    {
    193         //Get current instance of debug class
    194         $oDebug = self::get();
    195         //Add sql query to debug output
    196         $oDebug->query($query);
    197         //Pass back out from wordpress filter
     200        //Record query string
     201        self::get()->query($query);
    198202        return $query;
     203    }
     204   
     205    //add all available query data to debug
     206    private static function _processQueries()
     207    {
     208        foreach(self::getDB()->queries as $query)
     209        {   
     210            self::get()->query('[ function: '.self::queryCaller($query[2]).' ] '.' [ '.self::toSeconds($query[1]).' secs ] '.$query[0]);
     211        }   
     212    }
     213   
     214    //May have to test for array result but doubtful
     215    public static function queryCaller($callers)
     216    {
     217        $aCallers = explode(',',$callers);
     218        return $aCallers[count($aCallers)-1];
     219    }
     220   
     221    //Database data in millionseconds. Change to seconds before output to user.
     222    public static function toSeconds($milli)
     223    {
     224        return $milli * 1000;
     225    }
     226   
     227    //don't ask...umm cause its pretty?
     228    //This call provides a standard access method for the database
     229    //May be a long way away but we might see the end of global wpdb
     230    public static function getDB()
     231    {
     232        global $wpdb;
     233        return $wpdb;
    199234    }
    200235   
     
    247282        public static function add($sVar)
    248283        {
    249             $oDebug = self::get();
    250             $oDebug->add($sVar);
    251            
     284            self::get()->add($sVar);           
    252285        }
    253286        public static function dump($obj, $varName = '')
    254287        {
    255             $oDebug = self::get();
    256             $oDebug->dump($obj, $varName);
    257            
     288            self::get()->dump($obj, $varName);         
    258289        }   
    259290        public static function queryRel($sInfo)
    260291        {
    261             $oDebug = self::get();
    262             $oDebug->queryRel($sInfo);
    263            
     292            self::get()->queryRel($sInfo);         
    264293        }
    265294        public static function error($sInfo)
    266         {
    267             $oDebug = self::get();
    268             $oDebug->error($sInfo);
    269            
     295        {       
     296            self::get()->error($sInfo);
    270297        }
    271298        //shortcode entry point to debug
     
    287314
    288315//Add in admin options with link under settings "Debugger"
     316//Indent this big mess? Thank wordpress for that...This should all be javascript
    289317public static function admin()
    290318{
Note: See TracChangeset for help on using the changeset viewer.