Source for file Debug.php
Documentation is available at Debug.php
* DotBoost Technologies Inc.
* DotKernel Application Framework
* @copyright Copyright (c) 2009 DotBoost Technologies (http://www.dotboost.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @version $Id: Debug.php 152 2010-06-18 07:39:40Z teo $
* Few useful debugging functions . Planned to be replaced by ZfDebug version
* @author DotKernel Team <team@dotkernel.com>
* Display debugger for db
* Display details for db debugger on 1st load - if false,
* the user will need to click on the div to see details
* Allow display for db details
* Show or not total time box
* Show or not memory usage box
* @param Dot_Template $tpl
* @param string $propriety
public function __set($propriety, $value)
$this->$propriety = $value;
$stime = explode (' ', $this->startTimer);
$startTime = $stime[1] + $stime[0];
$endTime = $mtime[1] + $mtime[0];
$totalTime = 1000 * round (($endTime - $startTime), 3);
* Format the number, show miliseconds
* @param bool $miliseconds [optional]
private function numberFormat ($number, $miliseconds = false)
* Display the debug variables
$this->tpl->setFile('tpl_debugger', '../debugger.tpl');
$this->tpl->setBlock('tpl_debugger', 'zf_version', 'zf_version_block');
$this->tpl->setBlock('tpl_debugger', 'php_version', 'php_version_block');
$this->tpl->setBlock('tpl_debugger', 'dot_version', 'dot_version_block');
$this->tpl->setBlock('tpl_debugger', 'total_time', 'total_time_block');
$this->tpl->setBlock('tpl_debugger', 'memory_usage', 'memory_usage_block');
$this->tpl->setBlock('tpl_debugger', 'details_db_debug', 'details_db_debug_block');
$this->tpl->setBlock('tpl_debugger', 'db_debug', 'db_debug_block');
$this->tpl->setBlock('tpl_debugger', 'if_params', 'if_params_block');
$this->tpl->setBlock('tpl_debugger', 'no_params', 'no_params_block');
$this->tpl->setBlock('tpl_debugger', 'params', 'params_block');
$this->tpl->setBlock('tpl_debugger', 'queries', 'queries_block');
$this->tpl->setBlock('tpl_debugger', 'if_show_debug', 'if_show_debug_block');
// if we need to show total time - put this last so it counts the debug of queries, memory limit, etc
$this->tpl->parse('DEBUGGER', 'tpl_debugger');
$this->tpl->setVar('TOTAL_GENERAL_TIME', $this->endTimer());
$this->tpl->parse('total_time_block', 'total_time', true);
* Display DB querys for debug
$profiler = $this->db->getProfiler();
// lets see if we have the profiler active
if ($profiler->getEnabled() === true)
$this->tpl->setVar('INITIAL_DISPLAY', 'none');
$this->tpl->setVar('INITIAL_DISPLAY', 'block');
$profiler_queries = $profiler->getQueryProfiles();
foreach ($profiler_queries as $query)
$this->tpl->setVar('DEBUG_CLASS', 'debugger_'. $bc);
$this->tpl->setVar('QUERY_COUNT', $count++ );
$this->tpl->setVar('QUERY_TIME', $this->numberFormat($query->getElapsedSecs(), true));
$this->tpl->setVar('QUERY_TEXT', $query->getQuery());
if ($query->getElapsedSecs() > $longestTime)
$longestTime = $query->getElapsedSecs();
$longestQuery = $query->getQuery();
$queryParams = $query->getQueryParams();
if (count($queryParams) > 0)
foreach ($queryParams as $key => $val)
$this->tpl->setVar('QUERY_PARAMS', $val);
$this->tpl->parse('params_block', 'params', true);
$this->tpl->parse('if_params_block', 'if_params', true);
$this->tpl->parse('no_params_block', 'no_params', true);
$this->tpl->parse('queries_block', 'queries', true);
$this->tpl->parse('if_params_block', '');
$this->tpl->parse('no_params_block', '');
$this->tpl->parse('params_block', '');
$totalTime = $profiler->getTotalElapsedSecs();
$queryCount = $profiler->getTotalnumQueries();
// show aditional information
$this->tpl->setVar('TOTAL_QUERIES', $queryCount);
$this->tpl->setVar('TOTAL_TIME', $this->numberFormat($totalTime, true));
$this->tpl->setVar('AVERAGE_QUERY_TIME', $this->numberFormat($totalTime / $queryCount, true));
$this->tpl->setVar('QUERIES_PER_SECOND', ceil($queryCount / $totalTime));
$this->tpl->setVar('LONGEST_QUERY', $longestQuery);
$this->tpl->setVar('LONGEST_QUERY_TIME', $this->numberFormat($longestTime, true));
$this->tpl->parse('details_db_debug_block', 'details_db_debug', true);
$this->tpl->parse('db_debug_block', 'db_debug', true);
$this->tpl->parse('if_show_debug_block', 'if_show_debug', true);
$this->tpl->setVar('MEMORY_USAGE', $memory_limit);
$this->tpl->parse('memory_usage_block', 'memory_usage', true);
$this->tpl->setVar('ZF_VERSION', Zend_Version::VERSION);
$this->tpl->parse('zf_version_block', 'zf_version', true);
$this->tpl->parse('php_version_block', 'php_version', true);
* Display DotKernel version
$this->tpl->setVar('DOT_VERSION', Dot_Kernel::VERSION);
$this->tpl->parse('dot_version_block', 'dot_version', true);
|